Your Ad Here

Css writing styles


People have different styles for writing their CSS code. You want to aim for
maximum ease of readability and scan ability for yourself and anyone else
who may read your code after you.
Here are some ways of writing your style rules that can make your code
more readable.

Style rule all in one line
selector {property: value; property: value; property: value;}
Pro: All of the styles are on one line and thus easy to find in the document.
Con: It may be difficult to scan to find the property-value pair you are looking for.
Selector separated from style rules
selector {
property: value;
property: value;
property: value;}
Pro: The style-declaration block is on a separate line from the selector, which
can make it easier to find both the selector and the declarations.
Con: Breaking the declarations onto separate lines may cause the style-sheet
page to be marginally larger.


Selector separated from style rules, declarations
indented
selector
{
property: value;
property: value;
property: value;
}


Pros: The style-declaration block is on a separate line from the selector, and
with the declarations indented, it’s easy to distinguish between the selector
and the styles. Style declarations are easy to scan. You can add new declarations
without worrying about the end bracket.
Con: Breaking the declarations onto separate lines may cause the style-sheet
page to be marginally larger.
In all the cases above, the line breaks have no effect—the page will render
the same. There are many other slight variations, but ultimately, it just boils
down to your personal style. The way you think and find information visually
will determine what best works for you.


0 comments:

Post a Comment

Popular Posts

Recent posts