Are there any good CSS coding style/standards?
CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.
CSS standards ensure a Consistent application of style to a project making maintenance easier and minimizing style conflicts. Just as the information on a web page is semantically described in the HTML Markup, CSS describes presentation aspects of the page via a description of its desired visual properties.
The selector points to the HTML element you want to style. The declaration block contains one or more declarations separated by semicolons. Each declaration includes a CSS property name and a value, separated by a colon.
A CSS declaration block is an ordered collection of CSS properties and values. It is represented in the DOM as a CSSStyleDeclaration . Each property and value pairing is known as a CSS declaration. The CSS declaration block has the following associated properties: computed flag.
Here is a good one:
http://www.phpied.com/css-coding-conventions/
But the important thing is to pick something and stick with it for consistency.
I agree with most of the points at Andrew Hare's link, but I strongly believe
.class-name { color: green; }
is inferior to:
.class-name { color: green; }
on the grounds that:
.class-name, .class-name2 { color: green; }
or:
.class-name, .class-name2 { color: green; }
are considerably less obvious to grep or read than:
.class-name, .class-name2 { color: green; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With