CSS - SYNTAX Page-2
CSS SYNTAX
CSS BASICS TO ADVANCE TUTORIALS
CSS SYNTAX
CSS rules have two main parts, a selector and declarations
h1{ font-size: 1.5em; text-align: center; }
Syntax Explained:
In above syntax h1 is selector, font-size: is property, 1.5em is value.Again text-align: is property, center is value.
Combination of property and value is called as declaration.
Here we are styling h1 header text as it must be 1.5em in size and display in center.
A small example using above syntax:
Example
< !DOCTYPE html >
< html lang="en" >
< head >
< style >
h1 {
font-size: 1.5em;
text-align: center;
}
< /style >
< /head >
< body >
< h1 > Hello World! < /h1 >
< /body >
< /html >
< html lang="en" >
< head >
< style >
h1 {
font-size: 1.5em;
text-align: center;
}
< /style >
< /head >
< body >
< h1 > Hello World! < /h1 >
< /body >
< /html >
Note: A CSS statement must be end with a semicolon " ; ", and the total block of statements must be surrounded by the curly brackets "{ }".
Comments
A CSS comment begins with ' /* ', and ends with ' */ '.
Example
< !DOCTYPE html >
< html lang="en" >
< head >
< style >
/* This is comment line. */
h1 {
font-size: 1.5em;
text-align: center;
}
< /style >
< /head >
< body >
< h1 > Hello World! < /h1 >
< /body >
< /html >
< html lang="en" >
< head >
< style >
/* This is comment line. */
h1 {
font-size: 1.5em;
text-align: center;
}
< /style >
< /head >
< body >
< h1 > Hello World! < /h1 >
< /body >
< /html >
Comments
Post a Comment