CSS three written, you know?

CSS (Cascading Style Sheets)

English name: Cascading Style Sheets

  • CSS is a used to represent HTML (an application of Standard Generalized Markup Language) or XML (a subset of the Standard Generalized Markup Language) and other documents style computer language. CSS can not be statically modified pages, with a variety of scripting languages ​​can also be dynamically formatted for each element on the page.
  • CSS page layout can be on positions of the elements pixel-level precision control, supports almost all of the fonts in style, with the ability to model a web object and style editor.

CSS Three wording

Now that we know the style CSS for rendering HTML element tags, HTML is CSS is the cornerstone of the world. So, CSS to HTML by adding ways to play its role? The introduction of CSS code writing, there are three, we come one by one.

  1. Inline styles, use of "style" attribute in the HTML element;
  2. Nested styles, the style element in the HTML document using a head comprising a head region for CSS code;
  3. Outreach style, using an external CSS file.

"A" inline style

When a particular style needs to be applied to the individual elements, you can use inline styles . The method of using the inline style is used in the tag style attributes, style attributes may be any CSS property. Which is within the scope of the current label, the use of less

<body>
<div style = "color:blue; font-size:15px">文章</div>
<p>我是第一段文章内容</p> 
<p>我是第二段文章内容</p> 
<p>我是第三段文章内容</p> 
</body>

"Two" nested styles

When a single file requires special style, you can use nested styles . By nesting pattern writing style tags defined in the head portion, the label may be used in the style tag selector, class selector, id selector to set properties and other labels.

<title>文章</title>
<style>
       p{
       color: red;
       font-size: 30px;
       }
       div{
       font-size: 18px;
       }
 </style>

......

    <div>内容一</div> 
    <div>内容二</div> 
    <p>第一段</p> 
    <p>第二段</p> 

"Three" outreach style

When the style needs to be applied to many pages of time, you will use outreach style . So to change the style of pages by changing a file. At this point we need to introduce a link tag in the head tag. href for css files need to be introduced.

<head>
    <meta charset="utf-8" />
    <title>修改用户信息</title>
    <link href="Css/tableStyle.css" rel="stylesheet" />
</head>

Other

  1. Separate css files are .css file extension of the file can be set up in direct label style, you do not need to pack in the style tag
    Here Insert Picture Description
  2. When we want to set a special style to an element, the element can be written in the span / span tag, because there is no special semantic span tag, set the style for the individual.
<span>
      <p style="color:green;margin-left:20px;">
      这是一个段落
      </p>
</span>

summary

See CSS code from the storage position priority weight: inline style> internal stylesheet> outer style sheets. In addition to the above article situation, most programs are ultimately use CSS code outreach stylesheet.

Published 178 original articles · won praise 178 · views 90000 +

Guess you like

Origin blog.csdn.net/luckystar_99/article/details/89042632
Recommended