Four ways to use CSS style sheets in Web pages

Source: Internet
Author: User
Tags advantage
css| Page | style sheet

first, use the style attribute: Add the style attribute directly to the individual component labels.

< component (label) style= "Property (property) 1: Set value 1; Property (Attribute) 2: Set value 2; ...} For example:

<TD style= "Color:blue; font-size:9pt; font-family: "Superscript italics"; Line-height:150%>
The advantage of this usage is that it can be used neatly in each label, but the disadvantage is that there is no "uniformity" of the whole document.

second, use style tags: write style rules in <STYLE>...</STYLE> tags.

<style type= "Text/css" >
<!--
Style Rule table
-->
</STYLE>
For example:
<style type= "Text/css" >
<!--
Body {
Color:blue;
Background: #FFFFCC;
FONT-SIZE:9PT}
TD, P {
Color:green;
FONT-SIZE:9PT}
-->
</STYLE>

Usually the entire <STYLE>...</STYLE> structure is written in the <HEAD> </HEAD> part of the Web page. The advantage of this usage is the uniformity of the entire document, as long as the declared component will apply the style rule. The disadvantage is that the flexibility of individual components is insufficient.

Use the LINK tag: Write style rules in the. CSS style file, then introduce the <LINK> tag.

Let's say we put the style rules into a example.css file and we just add them to the page.
<link rel=stylesheet type= "text/css" href= "Example.css" >
You can apply this style file to a good style. The link tag is usually written in the

Use @import Introduction: Similar to link usage, but must be placed in <STYLE>...</STYLE>.
<style type= "Text/css" >
<!--
@import URL (the address, path, and filename of the introduced style sheet);
-->
</STYLE>
For example:
<style type= "Text/css" >
<!--
@import URL (http://yourweb/example.css);
-->
</STYLE>
Note that the semicolon at the end of the line is absolutely indispensable!



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.