Chapter Two the way of applying CSS

Source: Internet
Author: User
Tags advantage

One, a basic declaration: the most typical form of CSS declaration. element {Property:value} is expressed in Chinese, that is, the
symbol (label) {Property (property) Name: Set Value}
For example: H3 {Color:blue} is a set of declarations.
Second, collective declaration: A group or array style rule (the nature) that declares one or more components (labels) (tags) separated by commas (separated by semicolons). Symbol (label) {
Property (property) Name 1: Set value 1;
Property (attribute) Name 2: Set value 2;
...}
or
Symbol a (label a), component B (label B), component C (label C), ... {
Property (attribute) Name 1: Set value 1;
Property (property) Name 2: Set value 2;
...}
For example: TD {
Color:blue;
font-size:9pt;
}
or
Td,p,div {
Color:blue;
font-size:9pt;
}
Three-item declaration: Group many style rules and declare them separately. Component A (label a) {property (attribute) Name 1: Set value 1; property (attribute) Name 2: Set value 2;}
Symbol A (label a) {Property (property) Name 3: Set value 3; Property (property) Name 4: Set value 4;}
For example: td {Color:blue FONT-SIZE:9PT}
td {Font-family: "superscript italics"; line-height:150%} Such declarations do not contradict each other because the nature of the declaration is different. If you accidentally make a duplicate declaration of the same nature, only the set value that is later declared will work.
Incidentally, in your statement, you will be accepted as long as your format is correct, whether it is case, blank, or newlinewill not have any effect on the results displayed, you can write it in your own custom.
c s application

next to you Describes the four basic ways to apply the established style sheet to a Web page.

One, use the Style property: Add the Style property 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 cleverly applied in each label, But the disadvantage is that there is no "uniformity" of the whole document.
Two, use style tags: write style rules in <STYLE>...</STYLE> tags. <style type= "Text/css"
<!--
Style rules 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 writes the entire <STYLE>...</STYLE> structure on the Web page <HEAD> Third, use the LINK tag: Write style rules in the. CSS style file, then introduce the <LINK> tag. Suppose we save the style rule as a example.css file, we just add the
<link rel=stylesheet type= "text/css" href= "Example.css" to the Web page.gt; You can apply this style file to a good style. The link tag is usually written in the <HEAD> </HEAD> section of the Web page. The advantage of this usage is that you can assign several files of the same style rule to the same style file. Disadvantages are also insufficient flexibility in individual files or components.
Four, use @import Introduction: And link usage is very similar, but must put in <STYLE>...</STYLE>. <style type= "Text/css"
<!--
@import URL (the address, path, and file name 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 essential! Remember, remember!
Obviously, both link and @import may be able to apply directly to other people's existing style sheets. However, based on the Internet etiquette, this kind of thing do not do well, at least should also know each other's voice, must first obtain the consent of others!

and each of the four application methods have their advantages and disadvantages, and you can use them in a comprehensive manner without contradicting each other. However, if the same nature of the property in the case of repeated statements, it is necessary to consider the problem of applying precedence! Generally speaking, the order of priority has the following principles: Web Designer's style setting > user's style setting > browser's style setting
Style property's styling > styles label Style setting > link in the style setting
the style setting of the rear declaration, the previous style setting

The so-called "link in the style set" refers to the above mentioned link tag and @import introduced in the two application methods linked to the style of the set.

above is the most basic CSS Declaration and application method introduction, with these basic knowledge and methods, you can start to build your stylesheet! In addition to the basic declarations and application methods mentioned above, there are other methods of declaration and application that will be introduced in the next chapter.







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.