CSS multi-class selector

Source: Internet
Author: User

WrittenCodeMore, you will find that you are getting increasingly ignorant, always think that html css is very simple, has mastered very skilled, in fact, I am still a lot worse.

I have never used CSS in this way.. A. B {display: block ;}You only need to check the internet.

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

1. In HTML, a class value may contain a word list, separated by spaces. For example, if you want to mark a specific element as important and warning at the same time, you can write (the order of these two words does not matter, but can also be written as warning important):

 
<P class = "important warning"> This paragraph is a very important warning. </P>

Let's assume that all the elements whose class is important are in bold, while all the elements whose class is warning are in italic. All the elements whose class contains 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 two class selectors, you can only select the elements that contain these class names at the same time (the order of class names is not limited ).

If a multi-class selector contains a class name that is not in the class name table, the matching fails. See the following rules:

. Important. Urgent {Background: Silver ;}

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

 
<P class = "important urgent warning"> This paragraph is a very important and urgent warning. </P>

 

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.