CSS Selector Description _ Basic Tutorial

Source: Internet
Author: User
One, type selector
Body
{
font-size:12px;
}

{
Color:blue;
}
A selector for the name of a label type already in the Web page, as indicated above: All text size within the body tag is 12px, and the text color in the paragraph is blue.
Second, group selector
H4,p,span
{
font-size:12px;
}
Indicates that all H4,p,span labels in the page are 12px in size, that is, the same style is specified for a group of objects, and each label is separated by commas.
Third, include selectors
Div p
{
Font-weight:bold;
}
Indicates that the text in the P tag inside the div tag is in bold, this is a containment relationship, and each label is separated by a space and can be contained in multiple levels.
Iv. ID and Class selector
The ID is a style definition for the unique element in the page, which is used only once in the page, that is, the ID is not duplicated

..

#myDiv
{
font-size:12px;
}
class defines a common or frequently used style, a style that needs to appear multiple times on a page, meaning that you can specify the same class for different labels, as follows: The fonts in the div and P tags are blue


..


. Red
{
Color:blue;
}
Five, combination selector
Use an ID or class, and also use tags to combine
H1 #cont
{
}
Represents a h1 label with ID cont
H1. cont
{
}
Represents all H1 tags that are class cont
VI. Pseudo-Class selectors
Common as a label
A:link
{
}
A:hover
{
}
a:visited
{
}
Seven, pass with the selector
*
{
Color:blue;
}
Indicates that all objects have a blue font.
  • 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.