Internal stylesheets (ones that are defined within a <style> element) does not take precedence over linked stylesheets (<link rel="stylesheet" href=".."></link>).
Whichover is active depends on whichever has the highest specificity and if two selectors have the same specificity, the last one defined takes precedence.
Inline styles (<h1 style="color: blue">Hello World</h1>) does take precende over both the linked and the internal stylesheet.
Each CSS selector has a precise place in the hiearchy of precedence and if two selectors have the same precende level, the last one defined overwrites the latter (aka. taking precedence), but, this is due to inline styles having a higher specififty.
| Selector | Value |
|---|---|
!important | &inf; |
| Inline style | 10000 |
| CSS Identifiers | 100 |
| CSS Classes | 10 |
| HTML Elements | 1 |
| Example | Specificity Value | Explanation |
|---|---|---|
| p | 1 | One element |
| p .class | 11 | One element + one class |
| p .class #id | 111 | One element + one class + one id |
| .class | 10 | One class |
| #id | 100 | One id |
| body p span#id | 103 | body=1 p=1 span#id=101 => 103 |
Anything related to font, typography and color is inherited and everything else is not. An exception to this however is form elements which do not typically inherit font-settings.
body { font-size: 22px;} p { /* inherits body's fontsize */} button, input, textarea, select { /* Does not inherit fontsize */ /* To manually enable inheritance of font settings */ font: inherit;}Look for <span> elements nested inside a <p> elements.
p span { color: blue; text-transform: uppercase;}color: rgb(0,255,0) /* Completely green */color: rgba(0,255,0,0) /* Completely transparent */color: rgba(0,255,0,1) /* Completely green */color: rgba(0,255,0,0.5) /* 50% translucent green */color: #00FF00 /* Equal to: #0F0 */em is a multiplier based off of the parent element.
rem is a multiplier based off of the root element.
ch is useful for setting a max character width of a paragraph.
/* Anytime the fontname has a space in it, you have to enclose it in quotes */ol { list-style-type: none; padding: 0;}::marker { color: red; font-family: fantasy; font-size: .2rem; content: ">>"; /* This replaces the bullet point or whatever other decoration you have chosen */}Pseudo-classes represent the current state of an element (i.e. visited as in below).
a:visited { ...}The state of an anchor element can change, because it has either been visited or it hasn't.
Instead of staring with : the pseudo-element starts with ::
position: [static|relative|absolute|fixed|sticky];z-index property to change the order of overlapping elements.The default. It's already there and wont change anything.
top, bottom, left or right along with the position property.top, bottom, left or right along with the position property.top, bottom, left or right along with the position property.
Used to hide the element(s).
Can be used to wrap text around an element.
Defaults to left-to-right with wrapping
TODO
TODO
<section class="columns"> <p>...</p> <p>...</p> <p class="quote">... - Author</p> <h2>...</h2> <p>...</p> <p>...</p></section>.columns { column-count: 4; column-width: 250px; /* Minnimum width - it'll never go below that. It'll scale the column count down or up */ column-rule: 3px solid #333; column-gap: 2rem;} .columns p { margin-top: 0; /* Remove top-margin on first column*/} .columns h2 { background-color: #ccc; break-inside: avoid; /* Prevents the background of the block element from breaking unto two columns */ break-before: column; /* Makes sure the header is not shown at the end of a column */} .columns .quote { margin-top: 2rem; column-span: all;}