DEV Community

Cover image for Advanced HTML: Using Markup to Control State, Behavior, and UX
Daniel Trix Smith
Daniel Trix Smith

Posted on

Advanced HTML: Using Markup to Control State, Behavior, and UX

Most developers assume state = JavaScript.

That assumption is wrong.

Modern HTML already controls state transitions, interaction flow, and user intent — silently, efficiently, and reliably.

Advanced developers don’t fight this.

They design with it.


HTML Already Knows User Intent

Before JavaScript runs, the browser understands:

  • Click intent
  • Navigation intent
  • Submission intent
  • Focus intent
  • Cancel intent
<button type="submit">Save</button>
<button type="reset">Reset</button>
<button type="button">Cancel</button>
Enter fullscreen mode Exit fullscreen mode

Each button has built-in behavior.

Overriding this with JavaScript removes accessibility and expected UX.


State Exists Without Variables

HTML can express state declaratively.

<details>
  <summary>Show advanced options</summary>
  <p>Hidden content</p>
</details>
Enter fullscreen mode Exit fullscreen mode

No JavaScript.

No bugs.

No framework state.


Focus Is a Native State Machine

<form>
  <input required>
  <button>Submit</button>
</form>
Enter fullscreen mode Exit fullscreen mode

The browser:

  • Manages focus
  • Handles validation
  • Communicates errors
  • Prevents invalid submission

This is real UI logic — already implemented.


Navigation Is Built-in State

<a href="#pricing">See pricing</a>
Enter fullscreen mode Exit fullscreen mode

You get:

  • Scroll position
  • Browser history
  • Shareable URLs
  • Zero JS cost

HTML navigation scales better than custom routers.


Forms Control Application Flow

A form defines:

  • Entry point
  • Exit point
  • Validation rules
  • Submission lifecycle
<form method="post">
  <input name="email" required>
  <button>Continue</button>
</form>
Enter fullscreen mode Exit fullscreen mode

JavaScript should enhance this — not replace it.


Real State Attributes Matter

<input disabled>
<input readonly>
<input hidden>
Enter fullscreen mode Exit fullscreen mode

These states affect:

  • Accessibility
  • Keyboard navigation
  • Screen readers
  • Browser behavior

CSS-only states are invisible to assistive tech.


The DOM Is a State Tree

<button aria-expanded="true">
Enter fullscreen mode Exit fullscreen mode

Attributes describe state, communicate intent, and integrate with CSS and JS.


JavaScript Is an Upgrade Layer

Advanced HTML mindset:

  1. HTML defines structure and state
  2. CSS defines appearance
  3. JS upgrades interaction

If JS fails, the app still works.


Final Thought

HTML is not passive.

It controls behavior, manages state, and defines user flow.

If your app collapses without JavaScript, your HTML is doing nothing.

Advanced developers let the browser work for them.

Top comments (0)