Skip to content
← All Tools
๐Ÿ”’All processing in your browser ๐ŸšซNo uploads stored ๐Ÿ›ก๏ธPrivacy-first conversion tools โœ“No login required
Guide

HTML Best Practices: Writing Clean, Semantic, Accessible Markup

Bill Crawford — Developer Guide — 2026  ยท  Last updated November 01, 2025

HTML is deceptively easy to write badly. A page can look correct in a browser while being a maintenance nightmare, inaccessible to screen readers, slow to parse, and fragile to change. These practices help you write HTML that holds up over time.

Connect on LinkedIn โ†’

Format messy HTML instantly: Our HTML Formatter indents and beautifies HTML code โ€” paste in minified or messy markup and get clean, readable output.

Open HTML Formatter โ†’

Table of Contents

  1. Use Semantic Elements
  2. One H1 Per Page
  3. Always Include Alt Text on Images
  4. Use <button> for Actions, <a> for Navigation
  5. Form Accessibility
  6. Boolean Attributes
  7. Document Structure Checklist
  8. Loading Performance
  9. Performance: Core Web Vitals in 2026

Use Semantic Elements

Semantic HTML uses elements whose names describe their purpose: <header>, <nav>, <main>, <article>, <section>, <aside>, <footer>. Screen readers use these to build document outlines. Search engines use them to understand content structure. Use them correctly and your HTML is self-documenting.

<!-- Non-semantic: everything is divs -->
<div class="header">...</div>
<div class="nav">...</div>
<div class="main">...</div>

<!-- Semantic: structure is explicit -->
<header>...</header>
<nav aria-label="Main navigation">...</nav>
<main>...</main>

One H1 Per Page

The <h1> element should appear once and describe the page's main topic. Headings should be hierarchical โ€” don't skip from H1 to H4. Screen readers allow users to navigate by heading level, so a logical heading structure is a core accessibility requirement.

Always Include Alt Text on Images

Every <img> needs an alt attribute. If the image is informative, describe what it shows: alt="Bar chart showing 40% revenue growth in Q3 2025". If the image is purely decorative, use an empty alt: alt="" โ€” this tells screen readers to skip it. Never omit the attribute entirely.

Use <button> for Actions, <a> for Navigation

The distinction matters for keyboard accessibility and screen reader announcements. <button> triggers an action (submit, toggle, open modal). <a href="..."> navigates to a URL. Never use a <div onclick="..."> or a <a href="#"> (no real destination) for either purpose.

Form Accessibility

<!-- Every input needs an associated label -->
<label for="email">Email address</label>
<input type="email" id="email" name="email" 
       autocomplete="email" required
       aria-describedby="email-hint">
<span id="email-hint">We'll never share your email.</span>

<!-- Don't use placeholder as a label substitute -->
<!-- Placeholder disappears on input and has poor contrast -->

Boolean Attributes

Boolean HTML attributes don't need a value โ€” their presence alone means true. required, disabled, checked, readonly, multiple, autofocus are all boolean. Don't write required="true" or disabled="disabled".

Document Structure Checklist

Loading Performance

Add loading="lazy" to images below the fold. Add width and height attributes to images to prevent layout shift during load. Use <link rel="preconnect"> for critical third-party origins. Add defer or async to non-critical script tags.

Performance: Core Web Vitals in 2026

Google's Core Web Vitals are the primary performance metrics that affect search ranking. Understanding them helps you write HTML that performs well:

<!-- Always specify dimensions to prevent layout shift (CLS) -->
<img src="hero.jpg" alt="Product hero" width="800" height="600">

<!-- Preload LCP image to improve LCP score -->
<link rel="preload" as="image" href="hero.jpg" fetchpriority="high">

<!-- Lazy-load below-fold images (don't lazy-load the LCP image!) -->
<img src="product.jpg" alt="Product" loading="lazy" width="400" height="300">

Further reading: MDN โ€” HTML Learning Area ยท WHATWG HTML Living Standard

BC
Bill Crawford
Founder, Data Conversion Center

Bill Crawford is a data systems developer and technical founder with over 30 years of professional experience in accounting, finance, and business operations.

He holds a Bachelor's degree in Accounting and has spent more than three decades working within financial and operational environments. Over the past 10 years, he has been heavily involved in the development, implementation, and refinement of financial and enterprise data systems for both Fortune 500 companies and smaller organizations.

His work bridges finance and technology — combining deep domain knowledge in structured reporting and accounting workflows with hands-on SQL development and database architecture experience.

Bill founded DataConversionCenter.com to build practical, browser-based tools that simplify complex data challenges, including:

Rather than focusing on theoretical examples, his tools and articles are informed by real-world challenges encountered in enterprise reporting systems, financial databases, and operational data environments.

Professional Background

Bill's mission is to reduce friction in data workflows — particularly for professionals working with structured financial, operational, and reporting data.