View Single Post
Old 08-18-2025, 03:19 PM   #1
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 498
Karma: 65460
Join Date: Jun 2011
Device: Kindle
Ordering css styling within a given class

Honestly, this seems like the first question I should have asked when I started doing this...

But does it matter what order styles appear within a given class?

Specifically I'm thinking about things like font-size and margins, but i'm sure there are other similar examples. If you're using em units, the height of a margin will scale based on the font size. But I thought that html is read top to bottom, so in theory the code

Code:
p {
font-size: 2em;
margin-top: 1em;
}
should look diffierent than

Code:
p {
margin-top: 1em;
font-size: 2em;
}
since the first case has a margin that is equal to one line of 2em text (as font-size has been previously established), whereas I would think that the second has a margin that equal to 1em text as it hasn't "read" that the text is supposed to be 2em yet, and by the time it does it's already defined the height of the margin.

But it appears that NOT what happens; they both tend to look the same. Am I misuderstanding the way top-to-bottom works in HTML?
ElMiko is offline   Reply With Quote