Chapter 3 CSS application supplement

Source: Internet
Author: User

Before talking about the features of the selector, we should mention the features inherited by CSS. The inheritance feature means that the label inside the package will have the style property of the external label. The most typical application of inherited features is generally applied to the preset overall webpage style, and the part that needs to be specified as another style must be set in individual elements. This feature provides better space for web designers.
Next we will talk about the application of the selector feature! In fact, this part should be regarded as a declaration method, but after you have read the basic statements and applications in chapter 2, you will have a more conceptual point when talking about the selector here. In CSS application or design, there are several ways to set the display of specific properties based on the relationship or nature of elements, that is, the application of the characteristics of the selector, it makes your control and application more flexible.
1. Selector of the previous text: displays methods of a specific nature based on the relationship between the previous text and the last text of the declaration label.
When the browser displays the content specified by the original HTML code, the browser displays the pre-and post-relationship of the element label to display the specified style declaration. That is to say, as long as the tags in the original HTML code match the order before and after the arrangement, this statement will take effect!
Element A (label A) element B (label B) element C (label C )... {style rules} note that the declaration of the selector in the previous and later versions is similar to that of the collective declaration, but the element tags of the collective declaration must be separated by commas, the element labels must be separated by spaces when declared by the selector in the previous and later versions. You can use these two declaration methods in combination.
Element A, Element B, element C, element D,... {style rules}. In this way, you can declare the style rules of the selector before and after the array in the way of collective declaration.
II. Category selector: allows a single or multiple tags to use the same group style rules.
Class allows different element tags to apply the same set of style properties or element tags to different groups of style properties. First, we will introduce how to apply the same set of style properties to different elements, as shown in the following example.
<HTML>
<HEAD>
<STYLE>
<--
. Blue {color: BLUE}
-->
</STYLE>
</HEAD>
<BODY>
...
<H1 class = "blue">... </H1>
...
<P class = "blue">... </P>
...
</BODY> note that the CLASS name can be any small point before the declaration. To apply the style properties of different groups to the same element label, you can also apply the category attribute.
<HTML>
<HEAD>
<STYLE>
<--
P. blue {color: BLUE}
P. red {color: RED}
-->
</STYLE>
</HEAD>

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.