3.7 Ensure code follows good semantic practices
Use semantic markup free of optional or non-standard code, only using custom solutions when native ones are insufficient.
Criteria
- Semantic code: Machine-testable
Use accurate markup according to the relevant standard(s).- 0.5% of the Global Top 200 Websites Use Valid HTML
- Every HTML Element
- GPF – General Policy Framework (PDF) – 1.9 – Strategy (Interoperable Technologies)
- GPF – General Policy Framework (PDF) – 4.5 – UX and UI (Native Components)
- GR491 – 1-4006 – Information Over Presentation
- How Often Should We Speak About HTML Conformance?
- HTML: A good basis for accessibility
- HTML5 For Web Designers
- Is React Accessible? That’s the Wrong Question
- Jumping HTML tags. Another reason to validate your markup
- Mastering HTML
- Page bloat update
- Plain Vanilla
- Reducing Carbon Emissions On The Web
- Semantic HTML
- Semantic HTML: the foundation of web accessibility
- Semantic HTML5 Elements Explained
- Ten years of page bloat: What have we learned?
- Testing 10 JavaScript Frameworks on Their HTML Defaults
- The Carbon Impact of Web Standards (PDF)
- Understanding why Semantic HTML is important, as told by TypeScript
- United Nations SDGS – Goal 1 – Poverty
- W3C Validator
- Web Accessibility Lawsuits
- Web Standards: The What, The Why, And The How
- What is page bloat?
- Where Has All the Valid HTML Gone
- Optional features: Machine-testable
Remove optional HTML elements, attribute quotes, and default attributes when these do not negatively impact functionality, accessibility, or readability. Retain them when they enhance accessibility, maintain clarity without compromising on performance, or ensure consistent browser rendering. - Avoid non-standard code: Machine-testable
Avoid using non-standard HTML elements or attributes. - Custom code: Human-testable
Prioritize the use of standard HTML elements and attributes. Only use custom elements or Web Components if you cannot use native elements or if you require them for the purposes of producing reusable design system components.
Benefits
- Accessibility
Applying semantic approaches means your content will be easier to navigate via assistive technologies and keyboard. Many tags phave native semantics, reducing the need for additional tagging. This can also help technologies to better understand your content. better. - Conversion
Ensuring your code is efficient and works reduces the risk of broken features and users giving up. - Economic
Conforming to accessibility legislation and regulations avoid lawsuits and fines. - Environment
Following standards ensures users have a coherent experience – reducing bugs, saving time spent fixing bugs, and avoiding wasted resources. Bloated markup can otherwise lead to waste data, while broken markup can even trigger memory leaks. - Performance
Clean, modern code renders better than deprecated or poorly maintained code. While Web Components do outperform framework components, they cannot outperform the native elements they are built on.
GRI
- Materials: Medium
- Energy: Medium
- Water: Medium
- Emissions: Medium