Pick / run / change

HTML5 Editor with Live Examples

Pick an HTML5 feature, see a working example and change the code to learn how it behaves. Ten examples cover dialogs, collapsible sections, built-in form validation, new input types, canvas, templates and more, each with a live preview.

Ten editable examplesLive preview and consoleNo JavaScript library needed
Try it here

Try HTML5 features live

Choose an example, then edit the code. The preview updates as you type, and anything the example logs appears under it.

Options

Examples run in a sandboxed frame in your browser. Some controls, such as the date picker and color picker, look different in each browser because the browser draws them. All ten examples work in current versions of Chrome, Edge, Firefox and Safari.

HCODX / live preview
    HTML5

    What HTML5 gives you without JavaScript libraries

    Many interface pieces that once needed a plugin or a library are now built into the browser.

    A native element does more than look right. The dialog element keeps keyboard focus inside the open dialog and closes with Esc. A details element opens and closes with Enter or Space. A required email field refuses an address without an @ and tells the visitor why. Recreating that behavior by hand takes a surprising amount of JavaScript, and is easy to get subtly wrong.

    The examples use only HTML, CSS and a few lines of plain JavaScript where the feature calls for it, such as opening a dialog or drawing on a canvas. Change a value, delete an attribute or add your own element, and the preview shows the effect within a moment. Messages written with console.log appear under the preview, so you can see what a script did.

    Semantic elements such as header, nav, main, article and footer belong here too. They do not change how a page looks, but they describe its structure to search engines and give screen-reader users landmarks to jump between, which is why the semantic example matters as much as the interactive ones.

    Accessible by default

    Keyboard handling and screen-reader roles come with the element.

    Less JavaScript

    Validation, dialogs and disclosure widgets need little or no script.

    Edit and learn

    Change any example and the preview responds as you type.

    Learning

    How to learn from an example

    Reading code teaches less than changing it. Use each example as a starting point.

    01

    Run it as it is

    See what the example does and try every control before changing anything.

    02

    Change one thing

    Edit a single attribute or value, such as min on a number field, and watch the result.

    03

    Break it on purpose

    Remove an attribute such as required or method="dialog" to see which part does the work.

    04

    Take it with you

    Select Open in HTML Runner to keep editing, share a link or download the code.

    The HTML5 features guide on the blog explains each feature in more depth, with notes on when to use it.

    Native versus custom

    Why <dialog> beats a hand-made popup

    A modal built from divs needs code for focus, Esc and the background. The dialog element brings all three.

    Opening a dialog with showModal() puts it above the rest of the page, makes the page behind it inert, moves keyboard focus into the dialog and closes it when the visitor presses Esc. The ::backdrop pseudo-element styles the dimmed layer behind it with ordinary CSS.

    A form inside the dialog with method="dialog" closes it when a button is pressed and records that button's value in returnValue, so you can tell which choice was made without any extra event handlers.

    Styling a native dialog
    <dialog id="note">
      <p>Saved!</p>
      <form method="dialog"><button>OK</button></form>
    </dialog>
    
    <style>
      dialog { border: 0; border-radius: 12px; padding: 24px; }
      dialog::backdrop { background: rgb(0 0 0 / 0.5); }
    </style>
    
    <script>
      document.getElementById("note").showModal();
    </script>
    Keep going

    Try it, read about it, check it

    Three places on HCODX help you use HTML5 well.

    Try

    This editor

    Ten live examples you can change, with a preview and console output.

    Read

    HTML5 features guide

    An article on semantic elements, media, forms, data attributes and responsive images.

    Check

    HTML validator

    Find unclosed elements, missing labels and other mistakes in your own pages.

    Questions

    HTML5 editor questions

    HTML5 was the name of the big update that added the features on this page. Today the standard is simply called HTML and keeps evolving; a page that starts with <!DOCTYPE html> uses it.

    All ten examples work in current versions of Chrome, Edge, Firefox and Safari. Very old browsers may lack newer pieces such as :user-invalid, so test important forms in the browsers your visitors use.

    The browser draws native controls such as date, time and color pickers itself, so each browser and operating system shows its own version. The value your code receives is the same.

    Yes. Style them like any element, use ::backdrop for the layer behind a modal dialog, and style or replace the details marker on the summary element.

    No. It improves the experience in the browser, but anyone can bypass it, so the server that receives the form must check the data again.

    Select Open in HTML Runner. Your edits are kept there in your browser, and you can share them as a link or download them as a ZIP.

    Use HTML5 in a real project

    Build pages with these elements in the HCODX editor, with a file tree, live preview and ZIP export.

    Instant HTML Runner & Viewer with Live Preview

    Need to run a short HTML, CSS and JavaScript snippet? The HTML Runner Online has a focused editing surface with live output.

    Open HTML Runner Online