Subscribe:

Ads 468x60px

dropdown

Social Icons

CSS: CSS Syntax - Learn CSS for Free and Fun ......


CSS Syntax

A Cascading Style Sheet, whether embedded in the head element of an HTML document or
contained in a separate .css file is comprised of one or a series statements.

A Statement is basically an instruction that does TWO things:
 Identifies the elements in the HTML document which the statement will be affecting
 Instructs the browser how to display the elements

Each statement in the style sheet must conform to the CSS syntax.


The CSS syntax is comprised of THREE parts: a selector, a property and a value.

Selector: The HTML element or tag intended toe defined.
Property: The attribute intended to be changed.
Value: It specifies the property to aid in rendering it to specific media.

A simple CSS syntax is defined as: Selector {property: value;}

selector {property: value;}
The Selector is followed by the first left curly brace ("{"); the braces have the property and value inside them and the property and value are separated by a colon.

The following example shows a selector
body {color: black;}

If the value is defined by multiple words, they are written within quotes.
p {font-family: "courier new";}

If there is more than one property, they must be separated by a semicolon.

The following example shows how a left aligned paragraph with a blue text color must be
defined.
p {text-align:left;color:blue;}

It is a convention to describe one property in one line followed by another property in another
line, which also makes the style definition more  readable.

P{
text-align: left;
color: blue;
font-family: “courier new”;
}

0 comments:

Post a Comment