ID and class in Div + CSS

Source: Internet
Author: User

Class can be used repeatedly on the page,
Because the ID can only appear once on the page, it cannot be reused,
So try to use the class to write, so that you can repeat the CSS you write in the page to reduce the workload andCodeQuantity.

In this case, try to use ID: in the module with a large page, use ID to distinguish different modules.
For example, the page contains such modules as the latest news and recommendation news. You can consider using ID to distinguish.

Another point is that because ID is unique in the page, it is more defined for Javascript in the page.

Supplement: How to Use the class and ID on the page:

Code
Class:
<Style type = "text/CSS">
. Footer { Background : Red ; }
</Style> <Div class = "footer"> footer </div>
ID: <style type = "text/CSS">
# Footer { Background : Red ; }
</Style>
<Div id = "footer"> footer </div>

To define the class CSS, click:".", Such. Footer
CSS that defines the ID uses the"#", Such# Footer

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.