So I’m just starting on the product landing page. Im trying to format my header and am wondering why something ive stumbled upon is working.
For my header I have a img for the logo, text in for the title then and a ul of links for ‘about us’ ‘features’ and ‘pricing’.
Ive noticed when I type a number after the first line of code in my header div in CSS it aligns my ul to the right side. This is what I want but I want to know why. Im not typing any command before the number, not putting a semicolon after, literally just typing a number.
I think that that “random number” just breaks the CSS parsing. It doesn’t know what to do with it so it just stops. I can get the same effect with this:
header {
width: auto;
}
So, it just doesn’t read any of the lines after your “mistake”. I’ve found CSS parsers to be unforgiving.
Adding to what kevinSmith said, in CSS semicolons are separators between rules, and you having a number there is parsed as:
1 display: flex;
which is an unknown property name (1 display) so CSS just ignores everything until the closest semicolon.
You can use “Analyze CSS” command in CodePen to validate your CSS.
Also you can check in browser’s dev tools inspector how browser sees your CSS (btw, you have another typo):