How to insert CSS in the page


The first two chapters we know the CSS syntax, but to show in the browser results, we must allow the browser to identify and call. When the browser reads the style sheet, to follow the text format to read, here describes the four page insert in the style sheet approach: the chain into an external style sheet, internal style sheet, importing external style sheets and inline styles.

Chain into an external style sheet

Chain into an external style sheet is to the style sheet is saved as a style sheet file, and then used the page to link to this tag style sheet file, this tag must be placed page area , as follows:

... ...

... ...

The example above that from mystyle.css file browser to read the document format defined style sheets. rel = "stylesheet" refers to the page using the external style sheet. type = "text / css" refers to the style sheet file type is text. href = http://www.ddvip.com/web/html/index3/ "mystyle.css" is the file location.

An external style sheet file can be applied to multiple pages. When you change the style sheet file, all pages have followed the style change. The same style in the production of a large number of site pages, very useful, not only reduces duplication of effort, but also to future changes, editing, browsing, downloading code has also reduced duplication.

Style sheet files can use any text editor (for example: Notepad) to open and edit the general style sheet file name extension. Css. Content is defined style sheet, does not contain HTML tags, mystyle.css this document reads as follows:
hr (color: sienna)
p (margin-left: 20px)
body (background-image: url ("images/back40.gif"))
(As defined in the color to yellowish brown horizontal line; paragraph on the left of the blank margin of 20 pixels; page background image for the images directory back40.gif file)

Internal style sheet

Internal style sheet is the style sheet into the page district, the style of the application of these definitions to the page, and the style sheet is inserted