3 ms·
CSS isn't like most code. The sequence of lines has very little bearing on execution sequence. CSS is all about being well organised. If your selectors and att
by ra 17y ago
CSS isn't like most code. The sequence of lines has very little bearing on execution sequence.
CSS is all about being well organised. If your selectors and attributes are well organised, then one line CSS absolutely makes sense.
Group selectors by feature and order attributes uniformly. Very easy to read.
Much better to glance at the screen than scroll through a vertical column of formatting declarations.
- epochwolf 17y agoExcept that you can collapse everything between the braces and get every statement on one line by hitting alt+cmd+0 in textmate. When your editor can hide the details or navigate directly to the block you are looking for, formatting becomes less important for navigation.
- jules 17y agoBut then you can't read the actual CSS properties.
- rimantas 17y agoThe sequence of lines has very little bearing on execution sequence. Maybe I misunderstood what you said, bet sequence is important. When two separate rules (with the same specificity) match an element, the last one wins. There is a reason why devs learn LoVe-HAte mnemonics. For those who don't know it helps to remember the order of CSS rules for links: a:link, a:visited, a:hover, a:active. A:focus is getting more use recently, so usually it is stuck betveen V and H.
- ra 17y agoYou are correct, that's why I said 'very little bearing' rather than 'no bearing'. In practice, most of the time specificity is all that matters. I try to avoid 'last one wins' situations as they often mean you have written redundant CSS, hence making CSS harder to read :-)