CSS Basics +css Selector (element selector, relationship selector)

Source: Internet
Author: User

First I'll show you how to use the imported CSS style in an HTML page.

1. Inline style: <p style= "color:red" > inline style using css</p>

2. In-page style: set in the head tag

<span style= "FONT-SIZE:18PX;" >
3, External link method: First you have to prepare a good CSS style sheet outside
<span style= "FONT-SIZE:18PX;" >
Next I'm going to introduce CSS cascading styles like everyone

Element selector: class selector, ID selector, class selector, wildcard selector

Type selector: Select with the class label of the element

<span style= "FONT-SIZE:18PX;" ><style>        h1{        color:blue;        } </style></span>


ID selector:

<span style= "FONT-SIZE:18PX;" >


Class selector:

<span style= "FONT-SIZE:18PX;" >

Wildcard selector:

<span style= "FONT-SIZE:18PX;" >

The selection of the wildcard selector type is more abstract, use with caution!

Here we go. Introduction to relationship selectors: include selectors, sub-selectors, adjacent selectors, sibling selectors

Include selectors:

<span style= "FONT-SIZE:18PX;" >ul li{color:red;} </span>
All Li tags below the ul tag are styled


Sub-selectors:

<span style= "FONT-SIZE:18PX;" >
the sub-level element below the OL is selected


Adjacent selectors:

<span style= "FONT-SIZE:18PX;" >
Select the sibling-level Li element next to the LI tag


Sibling selector:

<span style= "FONT-SIZE:18PX;" >
Select all sibling level elements behind the LI tag


That's what I'm going to introduce.

Additional points to add:

First line indent: Text-indent:4em;

Center display: teext-align:center;

About the priority level:

Inline css> in-page css> external CSS

#id >.class

If you repeat the previous style, the style you set earlier is overwritten.

For example:


Specific to cover the abstract

For example, if you set the wildcard selection to match the element selector, the part that uses the element selector will not be overwritten with the wildcard selector.

CSS Basics +css Selector (element selector, relationship selector)

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.