CSS Common Properties First bullet: ID and class Selector

Source: Internet
Author: User
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 class= "P1";
this paragraph would also be center-aligned.

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.

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!

  • 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.