Home  >  Article  >  Web Front-end  >  Use CSS Selectors Cleverly_Experience Exchange

Use CSS Selectors Cleverly_Experience Exchange

WBOY
WBOYOriginal
2016-05-16 12:05:401367browse

Link styles in different content blocks can be defined through different rules. Something like this: #nav a:link or #main a:link or #footer a:link. You can also define different styles for the same elements in different content blocks. For example, define the styles of #main p and #sider p respectively through #main p and #sider p. Structurally speaking, your page is composed of pictures, links, lists, paragraphs, etc. These elements themselves do not affect which network device they are displayed on (PDA, mobile phone or Internet TV). They can be defined as Any performance appearance.

A carefully structured HTML page is very simple, and every element is used for structural purposes. When you want to indent a paragraph, you don't need to use the blockquote tag. Just use the p tag and add a CSS text-indent rule to p to achieve the indentation purpose. p is a structured tag and text-indent is a presentation attribute. The former belongs to HTML and the latter belongs to CSS. (This is the legendary separation of structure and performance)

There are almost no performance attribute tags in a well-structured HTML page. The code is very clean and concise. For example, the original code

can now just write
in HTML, all things that control the presentation All are written in CSS. In structured HTML, table is a table, not anything else (it cannot be used for layout and positioning).

Of course, CSS selectors are not just that simple. In addition to id and class, there are also descendant selectors, attribute selectors, etc.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn