Translation of CSS authoritative guide 3rd chapter 2 2.1.2 element Selector

Source: Internet
Author: User
2.1.2. Element Selector

If the selection is not unexpected, it is an HTML element, but everything is not absolute. For example, when the style contained in a CSS file is used for an XML file, the selector may look like this:

QUOTE {color: gray;}
BIB {color: red;}
BOOKTITLE {color: purple;}
MYElement {color: red;}


That is to say, the elements in the document are the most basic selector. In XML, the selector can be any element, as long as it is any element name in the new markup language of XML. On the other hand, if the style is applied for the HTML document, the selector is generally one of the HTML elements. Such as P, H3, em, A, or even HTML itself. For example:

html {color: black;}
h1 {color: gray;}
h2 {color: silver;}
 


The results of the style sheet are displayed in Figure 2-2.


Figure 2-2 simple styles in simple documents


Once you apply a style (global) to an element, you can shift the style from one element to another [1]. For example, if you want to apply the text in a paragraph rather than the H1 element, the figure 2-2 will be gray. Simple. Just change the selector H1 to P:

html {color: black;}
p {color: gray;}
h2 {color: silver;}

The result is shown in Figure 2-3.

Figure 2-3 The style will change as the element changes

Note 1: shift here should be the author's puntion. It's just like driving shift position.

Http://bbs.blueidea.com/thread-2789105-1-1.html

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.