The fourth chapter-First knowledge of CSS

Source: Internet
Author: User

1.CSS (cascading style sheets)
2.CSS syntax
selector {
Property name 1: attribute value 1;
Property Name 2: attribute value 2;
}
3. Three-way reference to CSS
First type: inline style
Example: <a style= "color:red;" > Internal Styles </a>
Second type: internal style
In the Head tab, write the style label.
Cases:
......
<style type= "Text/css" >
h1{
......
}
</style>
Third type: external style
Steps to use:
A) Create a file (CSS file) with a suffix of. css
b) Introduction of CSS files via link in HTML
<link rel= "stylesheet" href= "CSS file path"/>
4. Basic Selector
4.1 Tag Selector
Label name {}
Class 4.2 Selector
The. Class Property value {}
4.3 ID Selector
#id属性值 {}
5. Hierarchy Selector
5.1 descendant Selector
Parent element child element {}
5.2 Sub-selectors
Parent element > child element {}
5.3 Neighboring brother Selector
This element + adjacent sibling element {}
5.4 General Brotherhood Selector
This element ~ Sibling element {}
6. Structure pseudo-Class selector
E f:first-child{}//First child element
E f:last-child{}//Last child element
E f:nth-child (?) {}//? Represents the first few child elements, can also make odd odd, even even
E f:first-of-type{}//The first element of a specified type
E f:last-of-type{}//The last element of the specified type
E f:nth-of-type (?) {}//? Indicates the number of child elements of the specified type
Attention:
E F:nth-child (n) is found in the parent from an element, without typing.
E F:nth-of-type (n) Look at the type first in the parent, and then look at the position.
7. Property Selector
E[ATTR]//element with attribute attr
E[attr=val]//The value of the Attr property is the element of Val
E[attr^=val]//attribute attr The value of the element starting with Val
E[attr$=val]//attribute attr The value of the element ending in Val
E[attr*=val]//attribute attr The value of the element containing Val

The fourth chapter-First knowledge of CSS

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.