CSS stands for Cascading Style Sheets. It is a proper language to specify styles for a web page. From its development in 1994, CSS has been the only language to stylize HTML pages. Through CSS, different styles can be applied to a common element thereby enabling many styles on the same object.
Syntax:
Selector
{
Property: value;
Property: value;
Property: value;
Property: value;
}
Here in the first line you see a selector being declared. A selector is anything that needs to be stylized. Curly braces define the group of all properties that are applied on the selected object. Every property has a certain set of values amongst of which, a certain value is given there.
CSS can be used in three of the following ways-
In Inline CSS, properties are written within the tag itself having style as attribute.
Consider the code below:
Namaste! You're at ourtutorials.
Here three CSS properties are being applied to the paragraph that says: Namaste! You're at ourtutorials.
.
Output
Internal CSS is written within the head
part having style as internal tag.
Consider the code below:
Namaste! You're at ourtutorials.
Here three CSS properties are being applied to the selector p
that gets implemented on the only paragraph in body
saying again: Namaste! You're at ourtutorials.
.
Output
External CSS is written in a separate file having '.css' extension. All styles should be written one after another and the same file should be linked with the '.html' file in head
part.
Consider the codes below:
p
{
color:red;
background-color:lightgreen;
text-align:justify;
}
Namaste! You're at ourtutorials.
Here again three CSS properties are being applied to the selector p
(but in a separate file named: mystyle.css
). The CSS file is then linked to the HTML file using link
tag in the head
part. Finally the style applies to the only paragraph in body
saying again: Namaste! You're at ourtutorials.
.
Output