CSS style Selector

Source: Internet
Author: User
CSS is an abbreviation for the English cascading style sheets, called Cascading style sheets, to beautify the page. There are three ways of existence:

element inline, page embedding, and external ingestion. Compare the pros and cons of three different ways.

Syntax: style= ' key1:value;key2:value2; '

Use style= ' xx:xxx in the label; '

Embed in page: <style type= ' Text/css ' > </style> block

Introducing an external CSS file


Necessity: The American Union is responsible for the color collocation of the page and the beautification of the picture, and the developer must know how to achieve it.


See the above three ways to use it separately:

1. Use <style type= ' Text/css ' > </style> block in Label

<! DOCTYPE html>

2. Embed <style type= ' text/css ' > </style> block in the page

<! DOCTYPE html>

That is, add a <style></style> code block to your code, customize a style, and then you can call back and forth in the code that follows


3. Introduction of external CSS files

If you have more than one HTML file that needs to refer to a custom CSS style, then the second way is to define a style in each HTML file, in order to solve this problem, you can define a file, write a custom style, and then call the style from the file.

The style:

<style>    . logo{        background-color:red;    }    #logo {        background-color:red;    }    a,div{        color:red;    }    A div{        color:red    }    input[type= ' text ']{    color:blue    }    . logo a,.logo        p{font-size : 56px;    } </style>

1. Class Selector

When the logo indicates class= ' logo ', reference the style


2. ID Selector

#logo表示id = ' logo ', refer to this style


3, combination selector Selector

A,div indicates that all a tags and div tags refer to the style


4. Correlation Selector

A DIV represents a hierarchical relationship where the style is applied to the DIV tag under all a tags.


5. Attribute Selector

Input[type= ' text ', a property tag that indicates that all the type ' text ' tags refer to the style


6,. Logo A,.logo P denotes class= ' logo ', all of the following a label and class= ' logo ' when all the P tags below, reference the style

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.