CSS is the cascading style sheets, it is used to style a Web page.
It is a style sheet language which is used to describe the look and formatting of a document written in markup language.
Version | Year |
---|---|
CSS 1 | 1996 |
CSS 2 | 1998 |
CSS 3 | 1999 |
In this example all <p> elements will be center-aligned, with a blue text color:
p{
color: blue;
text-align: center;
}
CSS selectors are used to "find" (or select) the HTML elements you want to style.
The element selector selects HTML elements based on the element name.
Example
Here, all
<p>
elements on the page will be center-aligned, with a blue text color:
p {
text-align: center;
color: blue;
}
Example
The CSS rule below will be applied to the HTML element with id="p1":
#p1 {
text-align: center;
color: blue;
}
Example
In this example all HTML elements with class="c1" will be blue and center-aligned:
.c1 {
text-align: center;
color: blue;
}
The universal selector (*) selects all HTML elements on the page.
Example
The CSS rule below will affect every HTML element on the page:
* {
text-align: center;
color: blue;
}
h1, h2, p {
text-align: center;
color: red;
}