Class class and ID selector (. And #) in CSS)

Source: Internet
Author: User

in the previous days, the interview asked me if I could set the # number in CSS. I am not sure if I can use the # number. I will post it now.

use the class selector class and the identifier selector id to define the selector. The benefits are:
depending on the class or ID, you can express the same HTML element differently.
in CSS, the class selector is in a halfwidth English sentence ( . , the ID is prior to halfwidth English well number ( # .
example of a class: # top { background-color: # CCC; padding: 1em }< br> ID: . intro { color: red; font-weight: bold; }
call CSS connection attributes in HTML id and example of class :

id = "TOP"

chocolate curry

class = "Intro" This is my recipe for making curry purely with chocolate

class = "Intro" Mmm Mmmmm

the difference between ID and class is that ID is used on unique elements, while class is used on more than one element.

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.