Best practices for HTML.
Table of contents
Define important document properties
- Doctype - Enforce standards mode and consistent rendering.
- Language - Help search engines, translation tools and speech synthesis tools.
- Character encoding - Ensure proper text rendering.
- Page title - Help humans and bots to understand what the page is about.
Put stylesheets at the top
Ensure that styles are applied as early as possible during page render by placing all stylesheet links in the
Put scripts at the bottom
Prevent content being rendered from being blocked by placing all scripts just before the closing
Prefer specific elements to generic elements
Less markup, better readability.
Omit value for boolean attributes
Values for boolean attributes are obsolete and should be omitted.
- Define width and height - Prevent content from jumping around during page load.
- Define alt attribute - Help bots and search engines to properly index images.