How to insert a style sheet in HTML

Source: Internet
Author: User
Inline style table:Directly write it in the existing HTML, such as <P style = "color: Red"> text in red </P>

Embedded style sheet:Use the "<style> </style>" label to embed it into the header of an HTML file, for example, <style type = "text/CSS">
<! --
. Warning
{}{
Color: red
}
-->
</Style>

Note: The comment label in <style> is used to display the content of the style sheet on the screen when the browser does not support the style sheet.
External style table:
The external file of the sample table is extension .css, And the <link> label is used within the

The above three methods can be used as needed. However, in practice, external style tables are recommended based on the separation of performance and content. Their advantages are as follows:
1. It is independent of HTML files for easy modification.
2. Multiple files can reference the same style table file to ensure the uniformity of the page appearance.
3. You only need to download the style sheet file once and can use it on other pages linked to the file.
4. the browser displays HTML content first and then renders the content based on the style sheet file, so that visitors can see the content more quickly.
However, embedded style sheets and inline style sheets must be used flexibly in special cases.
In addition, there is a "imported style sheet", which uses "@ import" to import an external style sheet file, which needs to be written in the <style> label, for example: <style type = "text/CSS" Media = "all"> @importurl(basic.css); </style>

This is often used to replace the <link> tag connecting CSS to HTML. The advantage of this is that some old browsers do not accept the @ rule and do not connect to the style sheet. At this time, if the page has a good structure, the HTML with simple functions is left. Although there is no gorgeous appearance, visitors can still view the content well.

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.