when it comes to selectors everyone is not unfamiliar, the most estimated use is the ID selector and class selector, as for the other selectors, here today I avoided.
Class selector: The HTML element is given a loud name, tagged with class, you can use the class selector, such as <p class= "P1" > This is the paragraph 1</p> here I'll set the P element class
To "P1", and then write the CSS style can be used directly,
Give me a chestnut:
<style type= "Text/css" >
p.p1{color:red;}
</style>
</HEAD>
<BODY>
< P class= "P1";
this paragraph would also be center-aligned.
</P>
</BODY>
Run the previous piece of code, the class named P1 the text color of the P element is set to red, is not very simple, explain, non-P element class name P1 when no effect oh, want to all
The class class named P1 has an effect, you need to remove the previous structure element name. Now the project is Agile development, so use the class name to be careful, just beginning people often complain about
is the class name conflict, the result is that the style conflicts with each other, so we set a contract on the project, the page function to name the class name, so as to avoid the class name conflict.
Another thing to mention is a multi-class name:
<p class= "P1 Center" >
This paragraph'll also be center-aligned.
</p>
A class value can have this list, separated by a space between each word. Then write the style to write one by one is OK, here is estimated to be asked: if there are multiple classes between
What happens with the same CSS style! Here's a look at the following questions about CSS cascading! Today's article is here, the first write may be incoherent, may be thinking
What to write, look forward to gradually improve it!
More CSS Common Properties first bullet: ID and class selector related articles please follow topic.alibabacloud.com!