CSS learning (3) learning CSS style sheets (3) style sheet

CSS learning (3) style sheet

 

How to insert the stylesheet 1765243235

Method of inserting a style sheet in three ways:

  • External style sheet (External style sheet)
  • Internal style sheet (Internal style sheet)
  • Inline style (Inline style)

External style sheet

When the style needs to be applied to many pages, an external style sheet would be the ideal choice. In the case of an external style sheet, you can change the appearance of the entire site by changing one file. Each page uses the <link> tag to link to the style sheet. <Link> tag (document) header:

<head>
  <link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Note: Do not leave the unit between property values ​​and spaces (such as: "margin-left: 20 px"), correct wording is "margin-left: 20px".

Internal style sheet

When a single document requires a special style, you should use the internal style sheet. You can use the <style> tag defines internal style sheet in the document head, like this:

<head>
<style>
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
</style>
</head>

Inline style

Because you want to show and content mixed together, inline style loses many advantages out of style sheets. Use caution this method, for example, need only be applied when the style once in one element.

To use inline styles, you need to use the style (style) attribute in the relevant tag. Style attribute can contain any CSS property. This example shows how to change the color of the paragraph and left margins:

< P style = " Color: Sienna; margin-left: 20px " > This is a paragraph. </ P > 

Multiple styles priorities

(Inline style) Inline style> (internal style) Internal style sheet> (external style) External style sheet> browser's default style

How to insert the stylesheet 1765243235

Method of inserting a style sheet in three ways:

  • External style sheet (External style sheet)
  • Internal style sheet (Internal style sheet)
  • Inline style (Inline style)

External style sheet

When the style needs to be applied to many pages, an external style sheet would be the ideal choice. In the case of an external style sheet, you can change the appearance of the entire site by changing one file. Each page uses the <link> tag to link to the style sheet. <Link> tag (document) header:

<head>
  <link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Note: Do not leave the unit between property values ​​and spaces (such as: "margin-left: 20 px"), correct wording is "margin-left: 20px".

Internal style sheet

When a single document requires a special style, you should use the internal style sheet. You can use the <style> tag defines internal style sheet in the document head, like this:

<head>
<style>
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
</style>
</head>

Inline style

Because you want to show and content mixed together, inline style loses many advantages out of style sheets. Use caution this method, for example, need only be applied when the style once in one element.

To use inline styles, you need to use the style (style) attribute in the relevant tag. Style attribute can contain any CSS property. This example shows how to change the color of the paragraph and left margins:

< P style = " Color: Sienna; margin-left: 20px " > This is a paragraph. </ P > 

Multiple styles priorities

(Inline style) Inline style> (internal style) Internal style sheet> (external style) External style sheet> browser's default style

Guess you like

Origin www.cnblogs.com/hfdh435/p/11696185.html