What is the difference between ID and class usage in div

Source: Internet
Author: User
Keywords Web page production CSS Tutorials
Tags class content difference read set started the difference use

Just getting started friends may ask, when I use the ID when using class, after reading the following maybe you should understand the difference between ID and class.

Class is the label-setting classes

        ID is the identity of the set label

     The     class property is used to specify what style the element belongs to.

        such as style sheets can be added to

       . Title {

        font-size:14px;

        Font-weight:bold;

       }

        How to: class= the title

        ID property to define a unique style for an element.
&NBSP
        such as a CSS rule:

         #container

        {
         WIDTH:1004PX;
        margin:0 Auto;
        Text-align:lefT;
       }

        Usage: id= "container", ID is a label that distinguishes between different structures and content, just like your name, if a room has 2 people with the same name , you get confused;

        class is a style that can be nested on any structure and content, like a dress;

         The concept is different:
        ID is to find the structure/content, and then define the style Class is to define a style first, and then set it to multiple structures/content.

        hehe above said already very clear, regardless of ID or class can easily achieve special effects, simple and convenient, hope that this aspect of the people can be enlightened.

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.