Learn CSS Use tips tutorial (5) Customizing categories

Source: Internet
Author: User
Tags custom name
css| Skills | tutorials

Previous section: calling individually

  Custom Category

Today, there is a new knowledge "category". In fact, this knowledge is not unfamiliar! Recall that in the HTML tag, there is a property called class, which did not explain what the attribute was for. In fact, not without explanation, but the explanation will not be used, so I did not say for the time being, until today. This class attribute, so it's interpreted as a "category" attribute, what does it do? It allows us to use the same CSS settings in different tags, for example: when we are reading, we often see the key points in the textbook, marked with red or other colors. If, today on our web page, also want to some more important places with "red, bold word" to show, what would you do? :

Raw code "<font color=" Red "><b> Web Teaching network </b></font>"
Show results " Web Teaching Network "

  Use CSS to achieve focus

It's quite good to use the above Method! Simple to understand! However, imagine a situation ... If there are more than 1000 so-called "points" in our web page, you suddenly want to change the focus to "red, bold", then what should you do? At this time, we will talk about using CSS to help us solve the problem! Also, our "Custom category" is used!

Style syntax <style type= "Text/css" >
. important {color:red; Font-weight:bold}
</style>
Application Mode "<font class=" Important"> Web Teaching network </font>"

First of all, we are in the CSS table to do a class called important , and then use the class attribute, applied to the Web page, it is not difficult! In the future, if you want to change the "red" to "blue", then just change the settings in the category on the line! No matter the page has tens of thousands of "focus", do not be afraid!

  Use of custom categories

After reading the general usage of the custom category, and then to do a detailed explanation, how to customize the category? Custom Category method is very simple, the method and the general CSS Declaration No difference! The only difference is that the CSS declaration is for a label, and the custom category is not for a label, but to name it yourself!

Style syntax <style type= "Text/css" >
. important {color:red; Font-weight:bold}
</style>

For example,. Important {color:red Font-weight:bold} is our custom category, where the {} part is exactly the same as the normal CSS declaration Method! The difference is in the front . Important, that's right! Important is our custom name, with a name, in order to invoke. Attention! Remember to precede the custom name with a small dot ".", which completes a custom category! This class can be invoked using Class! Apply to any label!

Next section: Text Properties



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.