CSS Syntax

A CSS Rule is defined by a selector or more than one selector and one or more declaration.
Free CSS Tutorial

The Selector is normally the HTML Element you want to style, you can add as many selectors you want the CSS Document to affect in the selector field before the left curly brackets.

Example 1
CSS declaration is done by first grouping the declaration statements by opening a left curly bracket, writing out the declaration property followed by a colon, the value of the property followed by a semi-colon and closing the declaration group with a right curly bracket.


p { color: black; font-size: 12px; }

to make your CSS codes more readable, it’s always advisable to put each declaration on a new line when coding.


p
{
color: black;
font-size: 12px;
}

CSS Comments
Comments are used in CSS so that codes that are not used immediately can be used at a later period or probably in case you want to remember a particular style that has been given to a particular page on your HTML document on a latter date. the syntax for comments begin with /* and end with */

Example 2


body
{
color: black;
font-size: 12px;
/* ← comment begins
background-color: gray;
background-image: url('images/bg.png');
background-repeat: repeat-x;
comment ends → */
margin: 0 10px 0 10px;
text-align: left;
}

Back Main: CSS Programming Previous Lesson: Introduction Next Lesson: Backgrounds & Colors

One Response to CSS Syntax

  1. Olá! pessoal, estou com dificuldade de encontrar melhores soluções para o desenvolvimento do Layout do meu Web Site como os botões alguém me ajude?

Leave a Reply

Your email address will not be published. Required fields are marked *

Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar