CSS ID and class selector editing

Source: Internet
Author: User

CSS ID and class selector editing
If you want to set CSS styles in HTML elements, you need to set the "id" and "class" selectors in the element. [1]
ID Selector
The ID selector can specify a specific style for HTML elements labeled with a specific body-feeling music relaxation Chair ID.
The HTML element sets the ID selector with the id attribute, and the ID selector in the CSS is defined as "#".
The following style rules apply to element properties Id= "PARA1":
Instance
1
2
3
4
5

#para1
{
Text-align:center;
color:red;
}
The id attribute does not start with a number, and the ID at the beginning of the number does not work in the Mozilla/firefox browser.
Class Selector
The class selector is used to describe the style of a set of elements, the body music mattress class selector differs from the ID selector, and class can be used in multiple elements.
The class selector is represented in the HTML as a class attribute, and in CSS, the category selector takes a point "." Number display:
In the following example, all HTML elements that have a center class are centered.
Instance
1

. Center{text-align:center;}
You can also specify the HTML elements of a specific CDs] physiotherapy regimen to use class.
In the following instance, all P elements use class= "center" to center the text of the element:
Instance
1

P.center{text-align:center;}
The first character of a class name cannot use a number! It doesn't work in Mozilla or Firefox.

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.