HTML code standards

This document outlines the rules for writing HTML documents and fragments across all of our codebases.

General rules

We write HTML5 markup, following XHTML standards for readability.

General rules for all HTML documents are:

  • HTML documents should use HTML5 doctype - <!DOCTYPE html>

  • Indent using 2 spaces

  • Tags and attributes should be lowercase (<p class="intro"> not <P CLASS="intro">)

  • Use double quotes for attribute values

  • Close elements that are not void, i.e. add a closing tag at the end (<p>...</p>). You can leave void elements unclosed (<input> or <hr>).

Images

  • Use alt attributes on img elements

  • Use null alt text (alt="") and no title attribute on img elements for images that Assistive Technology should ignore

Accessibility

We aim to adhere to the Web Content Accessibility Guidelines (WCAG) 2.1.

This includes, but is not limited to:

  • Strict use of semantic HTML

  • Provide text alternatives for images, video and audio

  • Ensure suitable contrast and size for text

  • Make things keyboard accessible


Last updated 3 months ago.