3.8 Use HTML Elements Correctly
HTML semantics are important. They don’t just play a key role in making the Web look the way it does, they have a function in accessibility, SEO, and even in sustainability. Ensuring that you markup your content correctly and avoid cluttering your markup wastefully will reduce emissions.
Criteria
- Semantic Code: Content must be marked up semantically using the right HTML element for the right job.
- Optional Features: Remove optional HTML tags (which aren’t required for rendering), attribute quotes, or attributes that are set to their default value.
- Avoid Non-standard Code: Avoid using non-standard elements or attributes.
- Custom Code: Only use custom elements or Web Components if you cannot utilize native HTML elements or if you need tightly regulated control over the implementation of design system components.
Impact
Medium
Effort
Medium
Benefits
- Environmental:
Sites with bloated markup waste data, also sites with broken markup could trigger memory leaks (performance issues) in apps, and following standards ensures sites will work the same across devices and platforms (reducing bugs, developer fix time, and resource waste). - Accessibility:
Semantic HTML is a great stepping stone towards making your content easier to navigate by assistive technologies. Many tags within HTML5 come with pre-loaded context about what is expected within them (reducing the need for ARIA or other descriptive features). This can also help browsers, search engines, social networks, and other “blind” technologies understand your websites or applications better. This can help you reduce barriers in terms of content navigability. - Performance:
Deprecated code isn’t optimized within rendering engines, and while Web components do outperform framework components, they won’t beat the native HTML elements they build upon. - Economic:
Inaccessible sites can lead to lawsuits, avoiding these is beneficial to any website owner. - Conversion:
Poorly coded sites may break features for visitors, leading to website abandonment.
GRI
- materials: Medium
- energy: Medium
- water: Medium
- emissions: Medium
Example
- Code:
<header></header> <section> <article> <figure> <img> <figcaption></figcaption> </figure> </article> </section> <footer></footer>
- Semantic HTML5 Elements Explained.
Resources
- Deprecated HTML elements (and what to use instead)
- [GPFEDS] 1.9 – Strategy (Interoperable Technologies) (PDF)
- [GPFEDS] 2.9 – Specifications (Off-The-Shelf Components) (PDF)
- [GPFEDS] 4.5 – UX and UI (Native Components) (PDF)
- [GR491] 1-4006 – Information Over Presentation
- HTML: A good basis for accessibility
- Jumping HTML tags. Another reason to validate your markup
- Memory leaks: the forgotten side of web performance
- Optional HTML: Everything You Need to Know
- Reducing Carbon Emissions On The Web
- Semantic HTML
- Semantic HTML: the foundation of web accessibility
- Ten years of page bloat: What have we learned?
- The Carbon Impact of Web Standards (PDF)
- The history of deprecated and changed HTML tags
- Understanding why Semantic HTML is important, as told by TypeScript
- United Nations [SDGS] Goal 1 (Poverty)
- W3C Validator
- Web Accessibility Lawsuits
- Web Components Basics and Performance Benefits
- Web components vs. React
- Web Standards: The What, The Why, And The How
- What is page bloat?
- Why Do Some HTML Elements Become Deprecated?
- Why Web Components?