How CSS improves rendering performance

Source: Internet
Author: User

The habit of writing CSS determines the speed of page rendering, which is more obvious in IE. Developing good habits and standards will allow you to load your pages more quickly and enjoy a higher user experience. Below are some tips for improving CSS rendering speed, for your reference.

1. Do not use *{}
Some front-end developers often use * {margin: 0; padding: 0} to reset CSS. Although this method is easy to write, the browser engine needs to traverse all the labels after rendering, efficiency is greatly affected. We strongly recommend that you do not use it like this!
Recommended solution: process the tags you commonly use. For example: body, li, p, h1 {margin: 0; padding: 0 }, you can refer to the CSS reset code of a large website.

2. Use absolute location on the page.
Absolute positioning (position: absolute) is very common in web page layout, especially for some floating effects, it will make the page look very cool. However, because of the rendering mechanism of the browser, if you use too many absolute positioning in the webpage, it will make your webpage very slow.
Recommended solution: use as few as possible to achieve the same effect.

3. Inherit as many attributes as possible
Try to make some attributes inherit the parent element rather than overwrite the parent element.

4. CSS layers cannot be too many.
# Zishu. info. tool. sidebar h2 {font-size: 12px;}, which is not recommended, recommended syntax:. Zishu-s-h2 {font-size: 12px ;}.

5. Do not empty the class
Do not empty the class or the class that does not exist in the HTML code. This is meaningless.

6. Reasonable layout
A reasonable layout can change the CSS Writing and rendering process. You can refer to the layout of large websites for more information.

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.