CSS style Sheet Knowledge summary

Source: Internet
Author: User
Tags tag name

Classification

|------Inline in the label, accurate control, poor code reuse

|---------style= Style

<style= "background:yellow; width:100px; height:100px;" ></ Div >        <  style= "background:red; width:100px; height:100px;" ></ Div >

|------embedded in the

|---------<style type= "Text/css" ></style>

<style>#first{background:Pink;width:200px;Height:100px;}#second{background:Blue;width:200px;Height:100px;}        </style><DivID= "First">                    </Div>        <DivID= "Second">                    </Div>

|------External individual style files, control is not inline accurate, code reusability is best

|---------<link href= "" rel= "stylesheet" type= "Text/css"/>

#third {    background: purple;     width: 200px;     height: 300px;}
<rel= "stylesheet"  href= "1111.css"/>  <ID= "Third">                    </Div  >

Selector style sheet for selecting element tags: select elements based on tag name

|------Class

|---------. Point

|---------filter elements by class name

|---------can have duplicate names.

. Common {            width: 100px;             height: 100px;             background-color: black;             color: white;        }         . common:hover{            background-color: red;             Color: black;
<Divclass= "Common">I'm the first one to common .</Div>        <Divclass= "Common">I'm a second common .</Div>        <Divclass= "Common">I'm a third common .</Div>

|------ID

|---------#

|---------filter unique elements by ID name

|---------can't have duplicate names.

#third {              width: 100px;               height: 100px;               background-color: green;          }
<id= "Third">                    </Div  >

|------Composite

|---------comma: parallel div,span

|---------spaces: Descendants #list Li

|---------greater than sign: Child selector div>p all P tags in div

div,p {            border: 1px solid red;                    }         #third, #fourth{            border: 1px solid black;        }         #first_ul li{            color:brown;        }         #second_ul li{            color: darkblue;        }         #div_p >p{            color: green;        }
<DivID= "Third">                    </Div>        <DivID= "Fourth">                    </Div><ulID= "First_ul">            <Li>Disorderly One</Li>            <Li>Disorderly One</Li>            <Li>Disorderly One</Li>        </ul>        <ulID= "Second_ul">            <Li>Unordered two</Li>            <Li>Unordered two</Li>            <Li>Unordered two</Li>        </ul>        <DivID= "Div_p">            <P>I'm the first line in the div P element</P>            <P>I'm the second line in the div P element</P>            <P>I'm the third line in the div P element</P>            <Div>I'm the fourth line in the Div div element</Div>        </Div>

|------Property Selector

|---------[Property NAME = property Value]{} Property name can be added |, * and so on to match all attributes have attribute value of the element

|---------attribute selection for form elements

[href= "aa.html"] {            color: red;        }         input[type= "text"]{            background-color: Gainsboro;        }
<ahref= "aa.html">Jump</a>        <inputtype= "text"name=""ID=""value="" /><BR/>        <inputtype= "Password"name=""ID=""value="" />

|------pseudo-Class

|---------four pseudo-classes of a tag

|------------A:link links not visited

|------------links visited by a:visited

|------------a:hover mouse across the link

|------------a:active Selected Links

A:link {            color:red        }        a:visited{            color: black;        }         a:hover{            color: blue;        }         a:active{            color: yellow;        }
<href= "https://www.baidu.com"> jump to Baidu </ a >

CSS style Sheet Knowledge summary

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.