Lesson 36 +10 XP

HTML Cheatsheet

The grand recap! Here's the whole HTML story in one place. Skim this to refresh your memory any time.

The skeleton

Code

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Page Title</title>
    <link rel="stylesheet" href="styles.css">
  </head>
  <body>
    <! - visible content here - >
    <script src="app.js"></script>
  </body>
</html>

Structure tags

TagUse
&lt;header&gt;top of a page/section
&lt;nav&gt;navigation links
&lt;main&gt;main content (once)
&lt;section&gt;themed chunk
&lt;article&gt;standalone piece
&lt;aside&gt;side/related content
&lt;footer&gt;bottom of a page/section
&lt;div&gt;generic box

Text tags

TagUse
&lt;h1&gt;...&lt;h6&gt;headings
&lt;p&gt;paragraph
&lt;strong&gt; / &lt;em&gt;important / emphasized
&lt;a href=&quot;...&quot;&gt;link
&lt;ul&gt; / &lt;ol&gt; / &lt;li&gt;lists
&lt;dl&gt; / &lt;dt&gt; / &lt;dd&gt;description list
&lt;br&gt; / &lt;hr&gt;line break / divider
&lt;mark&gt; / &lt;small&gt;highlight / fine print
&lt;sub&gt; / &lt;sup&gt;below / above line
&lt;code&gt; / &lt;kbd&gt;code / keyboard

Media tags

TagUse
&lt;img src alt&gt;image
&lt;figure&gt; / &lt;figcaption&gt;image + caption
&lt;video controls&gt;video
&lt;audio controls&gt;audio
&lt;iframe src title&gt;embed another page
&lt;source&gt; / &lt;track&gt;media sources / subtitles

Table tags

TagUse
&lt;table&gt; / &lt;tr&gt;table / row
&lt;th&gt; / &lt;td&gt;header / data cell
&lt;caption&gt;table title
&lt;thead&gt; / &lt;tbody&gt; / &lt;tfoot&gt;table parts
&lt;col&gt; / &lt;colgroup&gt;columns

Form tags

TagUse
&lt;form action method&gt;the form
&lt;input type name&gt;a field
&lt;label for&gt;a label
&lt;button type=&quot;submit&quot;&gt;submit button
&lt;select&gt; / &lt;option&gt;dropdown
&lt;textarea&gt;long text
&lt;fieldset&gt; / &lt;legend&gt;group + title
&lt;datalist&gt;autocomplete suggestions
&lt;progress&gt; / &lt;meter&gt;progress / gauge

Handy attributes

AttributeUse
id / classunique / shared names
titlehover tooltip
lang / dirlanguage / direction
hiddenhide element
tabindexkeyboard focus order
data-*custom data
contenteditableeditable text
required / patternform validation
placeholder / autocompletehints / autofill
loading=&quot;lazy&quot;lazy load images

The golden rules

  1. Start with &lt;!DOCTYPE html&gt;.
  1. Use semantic tags: tell everyone what things mean.
  1. Always add alt to images and label to inputs.
  1. Write tags in lowercase.
  1. Keep the &lt;head&gt; for info, the &lt;body&gt; for content.

You've made it to the end: go build something amazing!