Formatting vendor-prefixed CSS

I’m a sucker for CSS conventions. Beyond CSS property order, general code formatting, spacing, and commenting are all up for some discipline. To keep things nice and tidy, and to save time in the future, I do my best to streamline my code. Figuring out…


This content originally appeared on @mdo and was authored by Mark Otto

I’m a sucker for CSS conventions. Beyond CSS property order, general code formatting, spacing, and commenting are all up for some discipline. To keep things nice and tidy, and to save time in the future, I do my best to streamline my code. Figuring out the right formatting for CSS properties, especially properties like border-radius and box-shadow, is near the top of my list.

Take for instance this block of CSS:

Straightforward enough. We have our vendor prefixes first, ordered by character length (a complex of mine I’m afraid), and ending with the official spec for that property. Great, but we can do better!

Ah, much better! Why? Well, if you’re a fan of code editors like Textmate, Coda, or Sublime Text 2, then you can easily edit multiple lines at a time. In Sublime Text 2—my editor of choice—I just have to hold Option while clicking and dragging to select multiple lines to edit.

With the values lined up, I can not only read my code faster and easier, but I can edit it faster and easier as well. A little bit of guidance on code formatting goes a long way for your own sanity, and those of your peers.


This content originally appeared on @mdo and was authored by Mark Otto


Print Share Comment Cite Upload Translate Updates
APA

Mark Otto | Sciencx (2011-12-06T00:00:00+00:00) Formatting vendor-prefixed CSS. Retrieved from https://www.scien.cx/2011/12/06/formatting-vendor-prefixed-css/

MLA
" » Formatting vendor-prefixed CSS." Mark Otto | Sciencx - Tuesday December 6, 2011, https://www.scien.cx/2011/12/06/formatting-vendor-prefixed-css/
HARVARD
Mark Otto | Sciencx Tuesday December 6, 2011 » Formatting vendor-prefixed CSS., viewed ,<https://www.scien.cx/2011/12/06/formatting-vendor-prefixed-css/>
VANCOUVER
Mark Otto | Sciencx - » Formatting vendor-prefixed CSS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2011/12/06/formatting-vendor-prefixed-css/
CHICAGO
" » Formatting vendor-prefixed CSS." Mark Otto | Sciencx - Accessed . https://www.scien.cx/2011/12/06/formatting-vendor-prefixed-css/
IEEE
" » Formatting vendor-prefixed CSS." Mark Otto | Sciencx [Online]. Available: https://www.scien.cx/2011/12/06/formatting-vendor-prefixed-css/. [Accessed: ]
rf:citation
» Formatting vendor-prefixed CSS | Mark Otto | Sciencx | https://www.scien.cx/2011/12/06/formatting-vendor-prefixed-css/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.