CSS Creation
When reading a stylesheet, the browser formats the HTML document according to it.
How to insert a stylesheet
There are three ways to insert a stylesheet:
- External style sheet
- Internal style sheet
- Inline style
External style sheet
When styles need to be applied to many pages, an external stylesheet is the ideal choice. With an external stylesheet, you can change the appearance of the entire site by changing a single file. Each page uses the tag to link to the stylesheet. tag in the head (of the document):
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>The browser reads the style declarations from the file mystyle.css and formats the document according to them.
An external stylesheet can be edited in any text editor. The file must not contain any HTML tags. The stylesheet should be saved with a .css extension. Below is an example of a stylesheet file:
hr
{
color:
sienna
;
}
p
{
margin-left:
20
px
;
}
body
{
background-image:
url
("/
images
/
back40
.
gif
")
;
}
Do not leave a space between the property value and the unit (e.g. "margin-left: 20 px"); the correct form is "margin-left: 20px".
Internal style sheet
When a single document needs special styles, you should use an internal stylesheet. You can use the
Do not leave a space between the property value and the unit (e.g. "margin-left: 20 px"); the correct form is "margin-left: 20px".