css-How to insert a style sheet

Source: Internet
Author: User
Tags insert

When you read a style sheet, the browser formats the HTML document according to it. There are three ways to insert a style sheet:
1. External style sheet
An external style sheet is an ideal choice when a style needs to be applied to many pages. In the case of using an external style sheet, you can change the appearance of the entire site by changing a file. Each page is linked to the style sheet by using a label. Label in (document) header:
CSS "href=" Mystyle.css "/>"
2. Internal style sheet
When a single document requires a special style, you should use an internal style sheet. You can use
3, inline style
Because you want to mix performance and content together, inline styles can lose many of the advantages of the style sheet. Use this method with caution, such as when a style only needs to be applied on one element at a time. To use inline styles, you need to use style attributes in the relevant tags. The Style property can contain any CSS properties. This example shows how to change the color and left margin of a paragraph:
This is a paragraph
Multiple styles
If some attributes are defined by the same selector in a different style sheet, the property value is inherited from a more specific stylesheet.
For example, an external style sheet has three properties for the H3 selector:
h3 {
color:red;
Text-align:left;
font-size:8pt;
and the internal style sheet has two properties for the H3 selector:
h3 {
Text-align:right;
font-size:20pt;
}
If this page with an internal style sheet is connected to an external style table, then the H3 gets the following style:
color:red;
Text-align:right;
font-size:20pt;
That is, the color properties are inherited from the external style sheet, while the text flow (text-alignment) and font dimensions (font-size) are replaced by rules in the internal style sheet.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.