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
- 36 elements in three tabs: every input type, textarea, button and a form builder; 12 text formatting tags; video, details, dialog, meter, progress and links.
- Attribute controls for each element, including validation (
required,min,max,pattern,maxlength),autocompletetokens and state (disabled,checked,open). - Accessible defaults:
label/forpairs,fieldsetandlegendfor groups, help text wired witharia-describedby,aria-labelledbyon dialogs and a requiredalton image buttons. - Warnings when a value would not work, such as a date in the wrong format, a meter value outside its range or autoplay without
muted. - Live preview in a sandboxed frame, and Copy HTML in one click.
- Shareable state: the address bar keeps
?mode=for the element you are on, so a link opens the same generator.
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.
| Type | What it does | Attributes worth setting |
|---|---|---|
text | Single-line free text. | maxlength, pattern, inputmode, autocomplete |
email | Checks the address format on submit and shows the @ keyboard on phones. | autocomplete="email", multiple for comma-separated lists |
password | Masks what is typed. | autocomplete="new-password" on sign-up, "current-password" on sign-in, minlength |
number | Numeric keypad on phones and spinner arrows on desktop. | min, max, step |
range | A 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 |
search | Text field with a clear button in many browsers and a Search key on mobile keyboards. | wrap in <form role="search"> or <search> |
tel | Phone keypad on mobile. Browsers do not validate phone formats. | pattern, autocomplete="tel" |
url | Rejects values without a scheme such as https://; keyboards add .com and / keys. | pattern, autocomplete="url" |
file | Native file chooser. The form needs method="post" and enctype="multipart/form-data". | accept="image/*", multiple, capture |
image | A graphical submit button. The click position is sent as name.x and name.y. | src, alt (its accessible name), width, height |
color | Native 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, week | Native 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 |
checkbox | Pick any number of options. Only checked boxes are submitted. A toggle switch is a restyled checkbox. | checked, shared name (add [] for PHP-style arrays) |
radio | Pick exactly one. Buttons with the same name form a group. | checked, required on the group |
submit | Submits 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.
| Tag | Meaning | Default look | Example |
|---|---|---|---|
<strong> | Importance or urgency | Bold | <strong>Do not unplug</strong> |
<em> | Stress emphasis; screen readers may change tone | Italic | I <em>really</em> mean it |
<mark> | Highlighted or relevant text, such as search matches | Yellow background | <mark>json</mark> formatter |
<u> | Unarticulated annotation, such as a misspelling | Underline | <u>recieve</u>; use CSS for decorative underlines |
<s> / <del> | s: no longer accurate (an old price). del: text removed in an edit | Strikethrough | <s>$49</s> $29 |
<sub> | Subscript: chemical formulas, indices | Lowered, smaller | H<sub>2</sub>O |
<sup> | Superscript: exponents, ordinals, footnote marks | Raised, smaller | x<sup>2</sup>, 1<sup>st</sup> |
<bdo> | Bi-directional override: forces dir="rtl" or "ltr" for every character, ignoring the Unicode bidi algorithm | Reordered text | <bdo dir="rtl">Invoice #4471</bdo> |
<q> | Short inline quotation | Language-appropriate quote marks | <q>Ship it.</q> |
<blockquote> | A longer quotation from another source; cite holds its URL | Indented block | Wrapped in <figure> with a <figcaption> when you give an author |
<cite> | The title of a creative work: book, film, article | Italic | <cite>The Pragmatic Programmer</cite> |
<code> | A fragment of computer code; wrap in <pre> for blocks | Monospace | <code>console.log("<b>")</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
- Video:
<source>elements with the right MIME type, an optional WebM fallback, a poster, a captions<track>and fallback text. Browsers only autoplay muted video, so turning on autoplay also addsmutedandplaysinline. MP4 (H.264) plays everywhere. - Details and summary: a disclosure widget that opens and closes without JavaScript. Give several
<details>the samenameto make an exclusive accordion. - Dialog: a modal opened with
showModal()gets a backdrop, focus trapping and Escape to close. The generated dialog hasaria-labelledbypointing at its heading and a<form method="dialog">that closes it and reports which button was pressed indialog.returnValue. - Meter shows a measurement in a known range, such as disk usage or a score, and colours itself using
low,highandoptimum. Progress shows how far a task has got; leave outvaluefor an indeterminate, animated bar.
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.