CSS Multi-Class Selector

Source: Internet
Author: User

Write more code, you will find that they are more and more ignorant, always thought HTML css is very simple, has mastered the very skilled, in fact, I am still a lot worse.

There is no use of CSS in peacetime . A.b{display:block;} The Internet is a check to understand.

Reference: http://www.w3school.com.cn/css/css_selector_class.asp

1. In HTML, a class value may contain a list of words separated by spaces. For example, if you want to mark a particular element as both important (important) and warning (warning), you can write (the order of the two words doesn't matter, warning important can be written as well):

<p class= "Important warning" >this paragraph is a very important warning.</p>

We assume that all elements of class important are bold, and that all elements of class warning are italic, and that all elements in class that contain both important and warning have a silver background. You can write:

. important {Font-weight:bold;}. Warning {font-weight:italic;}. important.warning {background:silver;}

2. By linking the two class selectors together, you can select only the elements that contain these class names (the order of the class names is unlimited).

If a multi-class selector contains a class name that is not in the list of class names, the match fails. Take a look at the following rules:

. important.urgent {background:silver;}

As expected, this selector will only match the P element that contains the word important and urgent in the class attribute. Therefore, if only the word important and warning are in the class attribute of a P element, it will not match. however , it can match the following elements:

<p class= "Important urgent warning" >this paragraph is a very important and urgent warning.</p>

CSS Multi-Class Selector

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.