3 ms·
I always write margin:0; instead of margin: 0; Here's why. The first reason I do is because you don't need to write that space. It doesn't seem like mu
by bbx 15y ago
I always write
margin:0;
instead of
margin: 0;
Here's why.
The first reason I do is because you don't need to write that space. It doesn't seem like much but it makes a difference when you're writing up to more than 1000 lines for one CSS (I type every word using Notepad++).
Second reason is: by removing this space, it joins the property (margin) and the value (0) together. And because I write my CSS in lines, it makes a difference when scanning visually.
input { background:white; border:none; float:left; font-size:14px; margin:0; padding:5px; width:400px;}
is easier for me to scan than
input { background: white; border: none; float: left; font-size: 14px; margin: 0; padding: 5px; width: 400px;}
because I can easily target any pair property/value.
And the reason I don't mind the lack of space after the colon is probably because I'm French and in French there needs to be a space before and after a colon. So I guess that if I remove the one before I might as well get rid of the one after (for symmetry?!).
- beaumartinez 15y agoI'd never thought of it that way. However, for me, input, select { background: white; border: none; float: left; font-size: 14px; margin: 0; padding: 5px; width: 400px; } Is more readable—each rule and selector on its own line. I am biased as I use Vim and half-page scroll lots, and like an 80-character maximum, though.
- bbx 15y agoI started writing CSS just like that. It makes reading properties easy but takes a lot of vertical space (and unlike you, I hate to scroll). So I write properties on one line, which makes reading selectors easy (example: http://jgthms.com/wings.css http://jgthms.com/wings.css). I compensate by ordering my properties alphabetically so I can scan horizontally to find any property (background and border come first, margin and padding are near the middle, text-transform and width are near the end...).
- MindTwister 15y ago> I compensate by ordering my properties alphabetically so I can scan horizontally to find any property (background and border come first, margin and padding are near the middle, text-transform and width are near the end...). Not a bad idea... I'm stealing it.
- prawn 15y agoI put "more likely to cause layout trouble" bits closer to the front where they'll be spotted more quickly. e.g., float, border, width, etc.