HTML and CSS, explained in plain English.
128 short pages, one for each tag, property and trick the lessons use. Each one says what the thing does, where it goes, and the mistakes people make with it, with an example you can open in the editor.
HTML tags and attributes
Every tag the HTML route teaches, plus the ones you will meet next: what each one does, where it goes and the mistakes people make with it.
layout
<main><main> wraps the one part of the page that this page is about.<header><header> wraps the intro at the top of a page: the logo, the site name, the main heading.<nav><nav> wraps a set of links for getting around: a menu bar, a sidebar of links, a breadcrumb trail.<footer><footer> wraps the bottom of a page: a copyright line, contact details, small links.<table> / <tr> / <td><table> shows data in rows and columns, like a spreadsheet.<th scope=""><th> is a header cell.<thead> / <tbody><thead> holds a table's header rows.<section> / <article>Two tags for the big parts of a page.<aside><aside> holds content that relates to the page but is not part of its main flow.<address><address> holds contact details for the author of the page or of an article.
grouping
<div>A plain box with no meaning and no look of its own.<span>The small version of <div>.class=""A name you give a tag, so CSS can find it later.id=""A name for exactly one tag on the page.<details> / <summary><details> is a built-in show and hide section.data-*=""data- attributes let you attach your own information to a tag.style=""style="" is CSS written on one tag.
links & media
<a href=""><a> makes something clickable and sends the visitor somewhere else.target="_blank" / rel=""target="_blank" opens the link in a new tab instead of leaving this page.<img src="" alt=""><img> puts a picture on the page.<figure> / <figcaption><figure> groups a picture with its caption, so the two are understood as one thing.<iframe><iframe> puts a whole other web page inside this one, in its own little window.<video><video> plays a video with the browser's own built-in player.<audio><audio> plays a sound clip with the browser's built-in controls.<svg><svg> draws a graphic with shapes described by math instead of pixels.<picture> / <source><picture> lets the browser pick between several versions of one image.
document
<!DOCTYPE html>The first line of every page: <!DOCTYPE html>.<html><html> wraps the whole page.<head><head> holds information about the page that visitors do not see on it: the tab title, the character set, linked CSS files, scripts.<title><title> sets the text in the browser tab.<body><body> holds everything visitors see: text, images, links, forms, all of it.<meta charset="utf-8">This tag tells the browser which character set your text uses.lang=""lang says what language the page is written in, like lang="en" for English.<meta name="viewport">This tag tells a phone to show your page at the phone's real width.
text
<h1> – <h6>Six sizes of heading.<p><p> marks a paragraph, the normal block of running text.<strong><strong> marks a few words as important.<em><em> marks words you would stress if you read the sentence out loud.<br><br> forces a line break inside text, like pressing Enter in the middle of a paragraph.<hr><hr> draws a horizontal line across the page.<small><small> marks fine print: a legal note, a disclaimer, a credit.<mark><mark> highlights text, like a yellow highlighter pen.<blockquote><blockquote> holds a long quote from somewhere else, as its own block.<code> / <pre><code> marks a short bit of code inside a sentence, like a variable name.<sub> / <sup><sub> drops a character below the line and shrinks it: H<sub>2</sub>O.<abbr><abbr> marks an abbreviation and spells it out in its title attribute: <abbr title="Cascading Style Sheets">CSS</abbr>.<time><time> marks a date or time and gives machines the exact value in datetime.<kbd><kbd> marks something the reader types or a key they press: Press <kbd>Ctrl</kbd> + <kbd>S</kbd>.
lists
<ul> / <li><ul> is a bulleted list, for a set of things where order does not matter.<ol> / <li><ol> is a numbered list, for things where the order matters: steps in a recipe, places in a race.<dl> / <dt> / <dd><dl> is a list of terms and their descriptions.
forms
<button><button> is a clickable button.<input><input> is a box the visitor types into or clicks.<label><label> is the text next to a form field that says what the field is for.<select> / <option><select> is a dropdown menu.<form><form> groups fields so they are all sent together when the visitor presses the button.<fieldset> / <legend><fieldset> groups related form fields under one title.<textarea><textarea> is a text box with more than one line: a message, a comment, a bio.checked / required / disabledThree attributes that are switches, not values.<input type="">One tag, many kinds of field.
other
<!-- comment -->A note for anyone reading the code later, including you.<script><script> runs JavaScript.<link rel="stylesheet"><link rel="stylesheet"> attaches a separate CSS file to the page.<style><style> holds CSS written straight into the page.<template><template> holds HTML that the browser reads but never shows and never runs.aria-label=""aria-label gives a tag a name for a screen reader (software that reads the page aloud).
CSS properties and selectors
The CSS you need to style a real page, from selectors and the box model to flexbox, grid and media queries.
attaching css
<style><style> holds CSS written straight into the page.<link rel="stylesheet"><link rel="stylesheet" href="style.css"> attaches a CSS file to an HTML page.selector { }Every CSS rule has the same shape: h1 { color: teal; }.specificity & the cascadeTwo rules can change the same thing on the same tag.--custom-propertyA custom property is a value you name once and reuse.!important!important makes one declaration beat every normal rule, whatever the specificity or order.inherit / initialFour keywords every property accepts.
selectors
.class.card picks every tag that has class="card", however many there are.#id#title picks the one tag with id="title".descendant & child selectorsTwo selectors joined together pick tags based on where they sit.:hover / :first-childA word after a colon narrows a selector by state or position.::before / ::after::before and ::after add an extra box inside a tag without adding a tag to the HTML.:focus / :focus-visible:focus picks the tag the keyboard is currently in, the one that reacts to Enter or typing.:nth-child() / :not():nth-child() picks tags by their position among their siblings.
the box model
box-sizingbox-sizing decides what width and height measure.marginMargin is empty space outside a box.paddingPadding is space inside a box, between its content and its edge.borderborder draws a visible line around a box, between its padding and its margin.width / heightwidth and height set how big a box is.border-radiusborder-radius rounds the corners of a box.max-width / min-heightLimits instead of fixed sizes.box-shadowbox-shadow draws a shadow around a box.
color & type
color & background-colorcolor sets the color of the text.font-family & font-sizefont-family lists the typefaces to try, in order.font-weight & line-heightfont-weight sets how bold text is: 400 is normal, 700 is bold.text-aligntext-align lines up the text inside a box: left, right or center.text-decoration / font-styletext-decoration draws a line under, through or over text.backgroundbackground is the shorthand for everything behind a box's content: a color, an image, a gradient, and how the image sits.text-transform / letter-spacingTwo small dials for text.@font-face@font-face loads a font file and gives it a name you can use in font-family.
display & flow
displayEvery tag is either a block or inline.positionposition changes where a box sits compared to its normal place.z-indexWhen two boxes overlap, z-index decides which is on top.overflowoverflow decides what happens when the content inside a box is bigger than the box.list-stylelist-style controls the bullet or number on a list.object-fitobject-fit decides how an image or video fills a box that is not its natural shape.float / clearfloat pulls a box to the left or right edge of its parent and lets text wrap around it.
flexbox
display: flexdisplay: flex goes on a parent tag.justify-content & align-itemsBoth go on the flex parent.flex-wrap & gapBy default, flex items squeeze onto one line even when they do not fit.flex-directionflex-direction sets which way a flex parent lays its items out: side by side (row, the default) or stacked (column).flex (grow / shrink / basis)flex is the one flex property that goes on the items, not the parent.
responsive basics
@mediaA media query wraps rules that only apply when a condition is true.rem / % / vwUnits that scale instead of staying fixed.calc()calc() lets a value be a sum, and it can mix units the browser could not otherwise combine.
interaction & polish
transitiontransition makes a change glide instead of snapping.opacityopacity sets how see-through a box is, from 1 (solid) to 0 (invisible).cursorcursor sets which mouse pointer shows over a box.transformtransform moves, scales, rotates or skews a box visually without moving anything around it.animation / @keyframesanimation plays on its own, with no hover or click to trigger it.
grid
display: griddisplay: grid turns a parent into a grid.grid-template-columnsgrid-template-columns defines the columns of a grid: how many, and how wide.grid-template-rowsgrid-template-rows is the row twin of grid-template-columns.grid-column / grid-row / grid-areaThese tell a grid item which cells it fills.
HTML email patterns
The tricks that make an email look right in Gmail and Outlook: layout tables, inline styles and buttons that survive every inbox.
why tables
role="presentation"Tells assistive tech this table isn't data — no row/column announcements, no "table with 3 columns" navigation mode — because it's only here for layout email clients otherwise force onto tables.nested centering tableCSS's margin: 0 auto isn't reliable across email clients.
inline styles
style="" (inline)Puts CSS directly on the element it styles, because a large share of email clients (Gmail among them, in some contexts) strip <style> blocks in <head> and ignore <link>-ed stylesheets outright — inline is the one styling method that survives almost everywhere.bgcolor + background-colorSets the exact same color twice, in two different syntaxes — the old HTML bgcolor attribute for clients that don't respect CSS backgrounds, and the CSS background-color property for the ones that do — so the fill renders consistently either way.
images & buttons
bulletproof buttonSolves the fact that Outlook (rendering with Word's engine) ignores CSS padding and border-radius directly on an <a> tag.width/height attributes on <img>Reserves the image's exact space in the layout before it loads — which matters far more in email than on the web, since a large share of clients block images by default until the recipient opts in.
client quirks
XHTML doctype + MSO conditionalsOutlook on Windows renders using Word's HTML engine, not a real browser engine — the XHTML 1.0 Transitional doctype is what that engine expects.preheader textMost inbox lists show a short preview snippet next to the subject line, pulled from whatever text comes first in the email body.