HTML Code Generator

Pick an element, set its attributes and copy clean, accessible HTML. Covers every form input type, buttons, a form builder, links, text formatting tags, video, details, dialog, meter and progress. Everything runs in your browser.

Live preview

What this HTML code generator does

Most snippets you copy from the web are missing the parts that make a control usable: the <label>, the name the server needs, the autocomplete token password managers look for, or the rel that keeps a new tab safe. This tool writes those for you. Choose a group above, pick an element, change its attributes, and the markup and a live preview update as you type. Text you enter is escaped, so a stray < or & can never break the output.

Features

HTML input generator

The Form inputs tab covers every <input type> that has its own behaviour. The type changes the keyboard shown on phones, the built-in validation and which attributes apply.

TypeWhat it doesAttributes worth setting
textSingle-line free text.maxlength, pattern, inputmode, autocomplete
emailChecks the address format on submit and shows the @ keyboard on phones.autocomplete="email", multiple for comma-separated lists
passwordMasks what is typed.autocomplete="new-password" on sign-up, "current-password" on sign-in, minlength
numberNumeric keypad on phones and spinner arrows on desktop.min, max, step
rangeA slider, 0 to 100 unless you change it. Pair it with <output> so the value is visible.min, max, step, value, list for tick marks
searchText field with a clear button in many browsers and a Search key on mobile keyboards.wrap in <form role="search"> or <search>
telPhone keypad on mobile. Browsers do not validate phone formats.pattern, autocomplete="tel"
urlRejects values without a scheme such as https://; keyboards add .com and / keys.pattern, autocomplete="url"
fileNative file chooser. The form needs method="post" and enctype="multipart/form-data".accept="image/*", multiple, capture
imageA graphical submit button. The click position is sent as name.x and name.y.src, alt (its accessible name), width, height
colorNative colour picker. The value must be a 6-digit hex such as #4f46e5; 3-digit hex is expanded for you.value, list for suggested swatches
date, time, datetime-local, month, weekNative pickers. datetime-local has no time zone.min, max, step in the formats 2026-09-26, 14:30, 2026-09-26T14:30, 2026-09, 2026-W39
checkboxPick any number of options. Only checked boxes are submitted. A toggle switch is a restyled checkbox.checked, shared name (add [] for PHP-style arrays)
radioPick exactly one. Buttons with the same name form a group.checked, required on the group
submitSubmits the form with no JavaScript. The label comes from value; placeholder is ignored.formaction, formmethod, formnovalidate

<textarea> is the multi-line control. It has no value attribute: its starting text sits between the tags, and a line break straight after the opening tag is dropped by the parser. Size it with rows and cols or CSS, cap it with maxlength (and enforce the same limit on the server), and add wrap="hard" with cols only if the submitted text must keep the visible line breaks.

HTML button generator

A <button> is focusable, works with Enter and Space and is announced as a button, none of which a styled <div onclick> gets without tabindex, role and key handling. Inside a form a button with no type submits, so the generator defaults to type="button". Set aria-label for icon-only buttons, and use Toggle to add aria-pressed for on/off buttons. A disabled button leaves the tab order and stops firing clicks, so for a short loading state aria-busy="true" plus a visual style is often the better choice.

HTML form generator

The Form builder turns one line per field into a complete, labelled form. Write Label | type | required, for example Email | email | required. Use select: A, B, C or radio: A, B as the type for choices, and textarea or checkbox for those controls. The builder adds matching autocomplete tokens for names, email, phone and URLs, switches to multipart/form-data when there is a file field, and ends with a submit button.

<form action="/contact" method="post">
  <div>
    <label for="email">Email</label>
    <input type="email" id="email" name="email" autocomplete="email" required>
  </div>
  <button type="submit">Send message</button>
</form>

HTML link generator

The link generator writes an <a> for a web address, an email (mailto: with an optional subject), a phone number (tel:, which opens the dialer on phones) or a section of the same page (#id). Opening in a new tab adds target="_blank" with rel="noopener noreferrer", which blocks reverse tabnabbing and hides the Referer. You can add nofollow, sponsored or ugc for paid and user-generated links, and download for files. Write link text that makes sense on its own: screen reader users often jump through a list of links, where “click here” says nothing.

HTML text formatting tags

The Text formatting tab wraps your text in the right element and escapes it. Tick Wrap each line separately to tag a list of lines at once.

TagMeaningDefault lookExample
<strong>Importance or urgencyBold<strong>Do not unplug</strong>
<em>Stress emphasis; screen readers may change toneItalicI <em>really</em> mean it
<mark>Highlighted or relevant text, such as search matchesYellow background<mark>json</mark> formatter
<u>Unarticulated annotation, such as a misspellingUnderline<u>recieve</u>; use CSS for decorative underlines
<s> / <del>s: no longer accurate (an old price). del: text removed in an editStrikethrough<s>$49</s> $29
<sub>Subscript: chemical formulas, indicesLowered, smallerH<sub>2</sub>O
<sup>Superscript: exponents, ordinals, footnote marksRaised, smallerx<sup>2</sup>, 1<sup>st</sup>
<bdo>Bi-directional override: forces dir="rtl" or "ltr" for every character, ignoring the Unicode bidi algorithmReordered text<bdo dir="rtl">Invoice #4471</bdo>
<q>Short inline quotationLanguage-appropriate quote marks<q>Ship it.</q>
<blockquote>A longer quotation from another source; cite holds its URLIndented blockWrapped in <figure> with a <figcaption> when you give an author
<cite>The title of a creative work: book, film, articleItalic<cite>The Pragmatic Programmer</cite>
<code>A fragment of computer code; wrap in <pre> for blocksMonospace<code>console.log(&quot;&lt;b&gt;&quot;)</code>

<bdo> only changes the visual order: the characters stay in logical order in the source, so screen readers and copy and paste still get the original text. CSS direction: rtl changes layout and alignment but still lets the browser reorder mixed-script runs; <bdo> suppresses that reordering.

Media and interactive elements

Need an embed or a data table? Use the HTML iframe generator for YouTube, Vimeo and Google Maps embeds, and the HTML table generator for tables built from a grid or pasted CSV.

Frequently asked questions

How do I make a generated form field accessible?

Give every control a visible label tied to it with a matching for and id pair, group related checkboxes or radio buttons in a fieldset with a legend, and connect help text with aria-describedby. A placeholder is not a label: it disappears as soon as the user types. The generator writes all of these by default.

Should I use button or input type="submit"?

Both submit a form and are keyboard accessible. A <button> can contain markup such as an icon and a text span, while <input type="submit"> can only show the plain text of its value attribute. Outside a form, use type="button" so a click never submits anything by accident.

Why does a link with target="_blank" get rel="noopener noreferrer"?

A page opened in a new tab can otherwise reach back to the page that opened it through window.opener, which is known as reverse tabnabbing. noopener cuts that link and noreferrer also stops the Referer header being sent. Modern browsers imply noopener, but writing it keeps older browsers safe.

What is the difference between strong and b, or em and i?

strong marks importance and em marks stress emphasis, so they carry meaning. b and i only change the look. Browsers render strong as bold and em as italic by default, but use them when the meaning matters and use CSS when you only want the style.

How do I open an HTML dialog as a modal?

Leave the open attribute off and call dialog.showModal() from a button click. A modal dialog gets a backdrop, makes the rest of the page inert, traps focus and closes with the Escape key. A form with method="dialog" inside it closes the dialog without any extra script.

Is the HTML I type sent to a server?

No. The code is built in your browser and the preview is a sandboxed frame on this page. Nothing you enter is uploaded or stored.