- The DOCTYPE cannot be missing. The browser determines the page rendering rules based on the DOCTYPE you declare. If it is not declared, different browsers may display different effects.
- Add the <meta> label before <title> to describe the code used on the page. Otherwise, the title of Some browsers may be garbled.
- <Style> should be placed in the
- Avoid using expressions in CSS. Otherwise, the browser recalculates the expression value every time the page content changes (for example, javascript dynamically adds or deletes elements and changes the browser window size. One alternative method is to use javascript to dynamically judge and confirm the style in window. onload. We should also cherish the resources of the user end.
- When using javascript to change the Display Effect of page Meta, use the className attribute whenever possible. Avoid using statements such as element. style. color = "# ff0000", especially when changing attributes multiple times at a time. There are two reasons for doing so: facilitating maintenance and saving client resources. When you use className to change a page, you only need to re-render the page once, and when the style attribute is changed, re-render the page every time, which is much higher than the overhead.
- The <script/> label should be placed before the </body> label. When the browser downloads the content in <script>, it does not download other content (images, flash, html files after <script>) at the same time. If a large number of external script files are used, this may result in loss of support and continues to wait for the patience displayed on the page.
A simple example:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">