Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the necessary common sense of CSS?

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what is the common sense of CSS". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In the early days, most Web markup consists almost entirely of tables and font elements, and does not convey any practical meaning to the content to be represented, making the document less available and difficult to maintain. So in 1995, the W3C issued a draft of CSS in an attempt to solve the problem of mixed structure and style.

1. If you consider that the structure is completely separated from the style, and the style sheet may be used for multiple HTML files, use an external style sheet

2. If the stylesheet is used only for the current page and the number of HTTP requests is reduced, use the internal stylesheet

3. If you just want to specify some styles for a single element, you can use the style property of HTML to set an interline style

Selector

Apply certain rules to a set of element types in a document through the CSS selector

1. Wildcard selector selects all elements

2. Element selector selects elements according to the HTML tag

3. The class selector selects a class of elements by defining the class name.

4. ID selector selects elements of a specific ID

5. The attribute selector selects elements according to their attributes and attribute values

6. The descendant selector selects elements through HTML hierarchical relationships.

7. The grouping selector merges elements with the same rules

Cascading

CSS (cascading style sheets) is cascading stylesheets translated into Chinese, and one of the most basic features is cascading. Conflicting declarations are sorted by cascading to determine the final document representation

In the following example, both the element selector div and the class selector .test can be selected, which leads to a conflict. Because the particularity of the class selector is greater than that of the element selector, the element is sorted by cascading, and the final style of the element is {height: 200px;}. If the rule .test {height: 200px;} is removed, the style of the element is {height: 100px;}

Div {height: 100px;} .test {height: 200px;}

Why Hack

CSS Hack is a way to achieve browser style compatibility, so try not to use it if you don't need it. However, for bug of some browsers, such as bug of the old version of IE, it is sometimes a last resort to use CSS Hack.

This is the end of the content of "what is the common sense of CSS". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report