How to use the css selector

Source: Internet
Author: User
Tags html page unique id

The previous article introduced the HTML structured css selector style in the css selector layout. This section describes how to use the CSS selector skillfully. Css skills div css skills and css layout skills as well as how to use css and css styles and other css selector usage methods
111cn.net

Id is used to identify the unique element of a page. The id is used to control a content block. By placing a content block into a div and assigning a unique id, you can use the CSS selector to precisely define the appearance of each page element, including the title, list, image, link, or paragraph. For example, if you write a CSS rule for # header, it is totally different from the image rule in # content.

 

Different rules can be used to define the link styles in different content blocks. Similar to this: # nav a: link or # main a: link or # footer a: link. You can also define different styles for the same element in different content blocks. For example, use # main p and # sider p to define the # main p and # sider p styles respectively. In terms of structure, your page consists of pictures, links, lists, paragraphs, etc, these elements themselves do not affect the network devices (PDAs, mobile phones, or network TVs) displayed on which they can be defined as any representation.

111cn.net


A carefully structured HTML page is very simple, and every element is used for structural purposes. When you want to indent a paragraph, you do not need to use the blockquote label. You only need to use the p label and add a CSS text-indent rule to p to indent the paragraph. P is a structured tag, text-indent is a manifestation attribute, the former belongs to HTML, and the latter belongs to CSS. (This is the separation of the legendary structure and manifestation)

111cn.net


The HTML page with a good structure has almost no labels showing attributes. The code is very clean and concise. For example, the original code <table width = "778" cellpadding = "3" border = "0" align = "center">, now, you can only write <table id = "MrJin"> in HTML. All control items are written into CSS. In structured HTML, table is a table, rather than anything else (not to be used for layout and positioning ).

Of course, CSS selectors are not just that simple, except for IDs, classes, descendant selectors, attribute selectors, and so on.

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.