Detailed explanation of CSS style creation

零下一度
Release: 2017-05-15 13:12:29
Original
1818 people have browsed it

When a style sheet is read, the browser formats the HTML document according to it.

How to insert a style sheet

There are three ways to insert a style sheet:

External style sheet

Internal style sheet

Inline Styles

External Style Sheets

An external style sheet is ideal when styles need to be applied to many pages. With external style sheets, you can change the look of your entire site by changing one file. Each page links to the style sheet using the tag. tag in the head (of the document):

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Copy after login

The browser will read the style declaration from the file mystyle.css and format the document according to it.

External style sheets can be edited in any text editor. The file cannot contain any html tags. Style sheets should be saved with a .css extension. Here is an example of a stylesheet file:

hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("/images/back40.gif");}
Copy after login

Do not leave spaces between the attribute value and the unit. If you use "margin-left: 20 px" instead of "margin-left: 20px" it will only work in IE 6, but not in Mozilla/Firefox or Netscape.

Internal style sheets

When a single document requires special styling, an internal style sheet should be used. You can define an internal style sheet at the head of the document using the