[CSS] Concise tutorial class in a style sheet

Source: Internet
Author: User
Tags format
css| Tutorial | style sheet class

In order to define the Web page format more accurately, it is necessary to make the same selectors can be categorized, and can be different categories for different style design. The basic format is as follows:

Selector. Category name {property: value}

A category name can be referenced in an character of an HTML ID:

< identifier class= category name > Web page content

Instance:

<title> CSS Example </title>
<style type= "Text/css"
!--
p.english{font-family: "Courier New"}
P.chinese{font-family: Young Round}
-->
</style>
<body>
<p Id=english>5dmedia Studio </p>
<p id=chinese> the original charm! </p>
</body>


   ID

ID, which is to send an "id" to the style in HTML text, to ensure that it has the only available value in an HTML document, and that this uniqueness is also handy for scripting languages such as JavaScript.

The use of IDs is similar to class, but it begins with a # sign rather than a dot.

Instance:

<title> CSS Example </title>
<style type= "Text/css"
!--
#English {font-family: "Courier New"}
#Chinese {font-family: Young round}
-->
</style>
<body>

</body>



   Pseudo class

In addition to the above classification methods, in order to make the use of classification more flexible and diverse, but also produced the concept of Pseudo-class. What is the difference between a class and a pseudo class?

Generally speaking, a selector can be set in bundles with multiple classes, so that although it can create many different styles for the same selector, the form of bundling also restricts the set class to be used by other selectors. Pseudo class is created to solve this problem, each of the predefined pseudo class can be referenced by all HTML identifiers, of course, some block-level content, except the settings.

In this case, only the most common type of anchor pseudo class in Pseudo class, the anchor pseudo class can specify a element to display the link in a different way, when the mouse encounters a link, a link that has been visited, and a link that is being activated, and a visited link can be defined as a different color display, font size, and style.

The basic format is as follows:

. Pseudo class Name {property: value}

A pseudo class can be referenced in HTML by any identifier.

< identifier class= pseudo class name > Web page content

Instance:

<title> CSS Example </title>
<style type= "Text/css"
!--
a:hover{font-size:18pt}/* when the mouse touches the link * *
-->
</style>
<body>
<a Href= "#" >5dmedia Studio </body>



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.