Interview questions and cheat sheets
HTML Tags Cheat Sheet: Common Tags by Purpose
HTML tags are best learned by purpose: structure the document, mark up text by meaning, link and embed media, build tables and forms, and use landmarks so assistive technology can navigate. This sheet covers the common tags in each group with when to use them and the mistake people most often make.
By CodingMarble · Published · 5 min read

Document structure and meta tags
Every page starts with a doctype and a html element that declares the language. The head holds information about the page, and the body holds what people see. The doctype keeps browsers out of quirks mode. The lang attribute helps screen readers choose a pronunciation and helps browsers offer translation, so leaving it out is a common and avoidable mistake.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Order status</title>
<meta name="description" content="Check where your order is.">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<main>
<h1>Order status</h1>
<p>Your parcel leaves the warehouse tomorrow.</p>
</main>
<script src="app.js" defer></script>
</body>
</html>- meta charset declares the character encoding; put it early in head, and use utf-8 so accented and non-Latin text displays correctly.
- meta viewport makes the layout fit phone screens; without it, mobile browsers render a zoomed-out desktop page.
- title is what appears in the browser tab and search results; give each page its own, and do not leave it as 'Document'.
- meta description supplies a summary that search engines may show; it is a suggestion, not a control, and it does not need keyword stuffing.
- link rel="stylesheet" loads CSS, and link rel="canonical" names the preferred URL for duplicate or similar pages; a common mistake is pointing every page's canonical to the home page.
- meta name="robots" content="noindex" asks search engines not to index a page; forgetting to remove it after launch is a classic reason a site does not appear in results.
- script with defer loads without blocking parsing; put scripts at the end of body or use defer, because a blocking script in head delays first paint.
Text semantics and lists
Choose a tag for what the text means, then style it with CSS. Headings h1 to h6 form an outline, so use one h1 per page for the main title and do not skip levels to get a smaller font. A p holds a paragraph, and using br to space paragraphs apart is the usual mistake: br is for line breaks inside one block, such as an address.
- strong marks important text and em marks stress; do not use them only for bold or italic looks, which is a job for CSS.
- b and i exist for text set apart without added importance, such as a product name; use them sparingly.
- blockquote holds a longer quotation and q holds an inline one; do not use blockquote just to indent text.
- code marks inline code, pre keeps whitespace and line breaks, and kbd marks keys a user presses.
- abbr with a title explains an abbreviation, and time with a datetime attribute gives a machine-readable date.
- span and div are generic containers with no meaning; reach for them only when no meaningful element fits.
- ul is an unordered list, ol is an ordered list and li is an item; every li must sit directly inside a ul or ol, and navigation menus are often best written as a list of links.
- dl, dt and dd form a description list for term and definition pairs, such as specifications.
Links, media and tables
The a element with an href creates a link. Link text should make sense on its own, so 'Read the delivery policy' beats 'click here'. If you add target="_blank", also add rel="noopener" for older browsers, and consider whether opening a new tab helps the user at all.
- img needs src and an alt attribute, plus width and height so the browser reserves space and avoids layout shift; writing alt text such as 'image of' is a common mistake, since screen readers already announce it as an image.
- picture with source elements lets the browser choose between formats or sizes, with an img inside as the required fallback.
- figure and figcaption wrap an image, chart or code sample with a visible caption.
- video and audio embed media; add controls, avoid autoplay with sound, and provide captions through the track element.
- iframe embeds another page; give it a title attribute describing its content, and load it lazily when it sits below the fold.
- table holds tabular data only, never page layout; a common mistake is using tables to position elements that CSS grid or flexbox should handle.
- caption, thead, tbody and tfoot structure a table, th marks header cells, and the scope attribute states whether a th heads a column or a row.
<table>
<caption>Delivery times by region</caption>
<thead>
<tr>
<th scope="col">Region</th>
<th scope="col">Standard</th>
<th scope="col">Express</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">North</th>
<td>4 days</td>
<td>2 days</td>
</tr>
<tr>
<th scope="row">South</th>
<td>5 days</td>
<td>3 days</td>
</tr>
</tbody>
</table>Forms and input types
A form groups controls that are sent together. Every control needs a label that is programmatically linked: a label element whose for attribute matches the input's id. Placeholder text is not a label, because it disappears while typing and is often low contrast. The right type attribute brings the right mobile keyboard and built-in validation for free.
- input type="text", email, tel, url, number, password, date, search, checkbox, radio, file and hidden cover most needs; use email and tel for their mobile keyboards, but remember browser validation is a convenience and the server must validate again.
- name decides the key the server receives; an input without a name is not submitted, a frequent source of 'my field is empty' bugs.
- autocomplete with values such as email or given-name helps browsers and password managers fill fields correctly.
- textarea takes multi-line text, select with option offers a list, and button with type="submit" sends the form; set type explicitly, because a button inside a form defaults to submit.
- fieldset and legend group related controls such as a set of radio buttons, giving them a shared name for screen readers.
- required, minlength, maxlength, pattern and min or max add browser-level validation rules.
<form action="/contact" method="post">
<div>
<label for="name">Full name</label>
<input id="name" name="name" type="text" autocomplete="name" required>
</div>
<div>
<label for="email">Email address</label>
<input id="email" name="email" type="email" autocomplete="email"
aria-describedby="email-hint" required>
<p id="email-hint">We reply within one working day.</p>
</div>
<fieldset>
<legend>Preferred contact</legend>
<label><input type="radio" name="via" value="email" checked> Email</label>
<label><input type="radio" name="via" value="phone"> Phone</label>
</fieldset>
<div>
<label for="msg">Message</label>
<textarea id="msg" name="msg" rows="5" required></textarea>
</div>
<button type="submit">Send message</button>
</form>Semantic landmarks and accessibility attributes
Landmark elements tell assistive technology where the parts of a page are, so a user can jump straight to the main content. Use header for introductory content, nav for major navigation blocks, main once per page for the central content, article for a self-contained piece such as a post, section for a themed group that has a heading, aside for related side content, and footer for closing information. A common mistake is wrapping everything in div elements, which removes all of that navigation help. Another is using section as a styling hook; use div when there is no heading and no meaning.
- alt on img describes the image's purpose; use an empty alt="" for purely decorative images so screen readers skip them, and never omit the attribute.
- label for connects a text label to a control, which also makes the label clickable and enlarges the target.
- aria-label gives an accessible name when no visible text exists, such as an icon-only button; prefer visible text when you can.
- aria-labelledby points to another element that already holds the name, and aria-describedby points to hint or error text.
- aria-hidden="true" hides decorative content from assistive technology; never put it on something focusable.
- The first rule of ARIA is to use a native element when one exists: a real button element beats a div with role="button" and extra scripting.
- Add a lang attribute on text in another language, and keep heading levels in order so the outline reads logically.
Practical tip: validate your markup with the W3C Nu HTML Checker, then tab through the page using only the keyboard. Together these two checks catch most structure mistakes, such as unclosed tags, missing labels and controls you cannot reach.
Keep reading
- Code snippetsCSS Button Hover Effects: Fill Slide, Press and FocusA good CSS button has distinct hover, focus-visible, active and disabled states, each changing only cheap properties like background, transform and box-shadow. Build the base button first, add a pseudo-element for the fill-slide hover, wrap hover in a media query for devices that can hover, and never remove the focus ring without replacing it.
- Code snippetsFlexbox vs Grid: When to Use Each, With ExamplesUse Flexbox when you are arranging items along one axis, such as a nav bar or a row of buttons, and use Grid when you need to control rows and columns together, such as a page layout or a card gallery. They work well side by side: Grid for the page and card structure, Flexbox for the content inside each cell.
- Web developmentResponsive Web Design Checklist for Real SitesA responsive site adapts to any screen width without horizontal scrolling, tiny text or unreachable buttons. Work through the viewport tag, fluid layout, breakpoints set by content, touch sizes, images, tables, forms and real-device testing, and check each one in your own pages.
- Interview questions and cheat sheetsVS Code Keyboard Shortcuts Cheat Sheet for Windows and MacThe VS Code shortcuts worth learning first are Quick Open, the Command Palette, multi-cursor selection, move line, rename symbol and the debugger step keys. Each is listed below as Windows/Linux key followed by the macOS key, and you can see or change any of them in the Keyboard Shortcuts editor.
Need this built properly for your business?
CodingMarble is a remote studio in India that builds websites, apps and games on fixed packages with the scope written down before payment. Try the free tools we run, or start a project when you are ready.