What is CSS?
Style sheets define how documents are shown on web pages.
With CSS, you can determine the number of style properties such as color, the size of text, font, and background colors for a given HTML element.
Each property has a name and a value and is separated by a colon (:). Each property statement is separated by a semi-colon (;).
Using CSS
There are listed below three ways of adding a style sheet in an HTML document:
- External– using a <link> tag
- Internal-using a <style> tag
- Inline –using the style attribute
External Style Sheet:
If you have to give exact look and feel to multiple pages then save all the style sheet rules in a single style sheet file. You can include a style sheet file into all HTML documents or pages using the <link> element.
<head> <link rel="stylesheet" type="text/css" href="style.css"> </head>
Internal Style Sheet:
In the internal style sheet, you can use CSS style to a single Html page only. You can define css rules in the <head>section and within a <style>element.
<head> <style type="text/css"> body {background-color: black;} h2 {color: green;} p {color: orange;} </style> </head>
Inline Style Sheet:
Inline Style Sheet is apply style sheet rules directly to any HTML element. These changes should be done only to a particular HTML element only. To use inline styles you can use the style attribute in the appropriate tag.
<h2 style="color:gree;">A Green h2 Heading here</h2> <p style="color:blue;">A blue paragraph here.</p>