We've all been there. You open an HTML file and see this:
<button onclick="submit()" disabled type="submit" aria-label="Submit form" class="btn" id="submit-btn">
  Submit
</button>
Or maybe this:
<button type="submit" id="submit-btn" onclick="submit()" class="btn" aria-label="Submit form" disabled>
  Submit
</button>
Both are valid HTML. Both work perfectly. But which one is "correct"?
Repo: https://github.com/lakhbawa/HTML-Attribute-Ordering-Standard (Please star the repo to help others)
The Problem
HTML doesn't care about attribute order. Your browser doesn't care. But humans do. When every developer on your team orders attributes differently, your codebase becomes harder to read, review, and maintain.
Think about it: how much time have you wasted scanning through a long list of attributes to find the id? Or tracking down that event handler buried in the middle? These small moments add up.
Introducing HAOS
I've created the HTML Attribute Ordering Standard (HAOS) - a comprehensive, community-driven approach to organizing HTML attributes consistently.
The core principle is simple: attributes should be ordered by their purpose and importance.
The 11-Category System
HAOS organizes attributes into 11 categories:
- 
Identification (
id,class,name) - 
References (
for,form,list) - 
Structural (
type,href,src,alt) - 
Data (
data-*attributes) - 
Accessibility (
role,aria-*,tabindex) - 
Form-Specific (
placeholder,required,disabled) - 
Media (
width,height,controls) - 
Behavioral (
draggable,contenteditable,loading) - 
Styling (
style) - 
Event Handlers (
onclick,onchange, etc.) - Custom (non-standard attributes)
 
Before and After
Before (chaos):
<input placeholder="Enter email" onclick="validate()" type="email" 
       required class="form-input" id="user-email" aria-label="Email address">
After (HAOS):
<input 
  id="user-email"
  class="form-input"
  type="email"
  aria-label="Email address"
  placeholder="Enter email"
  required
  onclick="validate()">
See the difference? The most important identifying information (id, class) comes first, followed by structural details, accessibility, form specifics, and finally event handlers.
Why This Matters
1. Faster Code Reviews
When attributes follow a predictable pattern, reviewers can focus on logic changes rather than hunting for specific attributes.
2. Reduced Cognitive Load
Your brain doesn't have to work as hard to parse HTML when attributes appear in expected locations.
3. Better Diffs
Consistent ordering makes Git diffs more meaningful. Attribute changes are easier to spot when everything else stays in place.
4. Easier Onboarding
New team members learn one pattern instead of adapting to each developer's personal style.
5. Automation-Friendly
Standardized ordering makes it easier to write linters, formatters, and other tooling.
Real-World Example
Here's a complex input field following HAOS:
<input 
  id="email-input"
  class="form-control"
  name="user_email"
  type="email"
  value="user@example.com"
  data-validation="email"
  aria-describedby="email-help"
  placeholder="Enter your email"
  required
  autofocus
  autocomplete="email"
  minlength="5"
  maxlength="100"
  pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$"
  oninput="validateEmail(this)">
Every attribute has its place. No guesswork needed.
Framework Support
HAOS includes specific guidance for modern frameworks:
React/JSX:
<input
  id="username"
  className="form-input"
  type="text"
  value={username}
  aria-label="Username"
  required
  onChange={handleChange}
/>
Vue.js:
<input
  id="username"
  class="form-input"
  type="text"
  :value="username"
  aria-label="Username"
  required
  @input="handleInput"
/>
Getting Started
The full standard is available on GitHub [link to your repo]. It includes:
- Detailed rationale for each category
 - Dozens of real-world examples
 - Framework-specific guidelines
 - Implementation strategies
 - Tooling recommendations
 
Quick Adoption Tips
- Start small: Apply HAOS to new code first
 - Use tooling: Set up ESLint or Prettier rules
 - Team buy-in: Share the standard with your team
 - Be consistent: Make it part of your code review checklist
 - Stay flexible: Adapt the standard to your team's needs
 
The Big Picture
HAOS isn't about being pedantic. It's about reducing friction in our daily work. It's about spending less time parsing HTML and more time building features.
Standards like this work because they remove tiny decisions from our day. Should id come before class? Don't think about it - just follow the pattern. Over thousands of elements across dozens of files, that mental energy adds up.
Join the Discussion
This is a community standard. It's meant to evolve based on real-world usage and feedback.
What do you think? Does your team have different conventions? Are there edge cases I missed? I'd love to hear your thoughts in the comments.
Let's bring some order to the beautiful chaos of HTML. 🎯
Repository: https://github.com/lakhbawa/HTML-Attribute-Ordering-Standard
Full Standard: https://github.com/lakhbawa/HTML-Attribute-Ordering-Standard/blob/main/README.md
Found this helpful? Give it a ❤️, Star the repo and share it with your team!
              
    
Top comments (0)