Read "Mastering CSS"

Source: Internet
Author: User

The first chapter:

1. The meaning of label semantics: it can make people, programs and other devices easier to identify and understand, so that the structure of the document becomes clear. You can easily adjust the elements to the desired style, avoiding unnecessary code bloat.

2. Since the available semantic elements are not comprehensive, most developers use existing elements to give meaning to them by adding IDs or class names. This adds an extra structure to the document and provides a useful "hook" for the style.

3. Naming: Keep the name independent of the form of presentation. Name it based on what it is, not how it looks. The great advantage of meaningful class names is that they can be reused throughout the site.

ID: Used to identify specific elements on a page, such as site navigation, and must be unique.

Class name: Can be applied to any number of elements on the page.

4. ID or class?

General principles: Classes should be used for conceptually similar elements that can appear in multiple locations on the same page. The ID should be used for different unique elements and should only be used if it is absolutely certain that the element will only occur once.

"Multi-class syndrome": Overuse of the class control style to add meaningless code to the document. This over-reliance on the class name is completely unnecessary. If you find that you have added many classes, this most likely means there is a problem with the structure of the HTML document.

5. "Multi-div": Excessive use of Div, which is an unreasonable and overly complex code structure signal.

In order to minimize unnecessary markup, you should use DIV elements only if no existing elements are able to achieve region segmentation.

6. A DTD (document type definition) is a set of machine-readable rules that define what is allowed in a particular version of XML or HTML and what is not allowed.

When parsing a Web page, the browser uses these rules to check the validity of the page and take appropriate action.

The browser knows which version of HTML to use by analyzing the DOCTYPE declaration of the page to see which DTD to use.

7. Validation: The Web Validator (bookmarklet) or the plug-in of the Firefox Developer extension Verify that the HTML is valid.

Read "Mastering CSS"

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.