DM
Technical reference

HTML Cheatsheet

Markup for the web

Getting Started

hello.html

Basic HTML Template

A boilerplate HTML5 document.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML5 Boilerplate</title>
  </head>
  <body>
    <h1>Hello world, hello DevMarks!</h1>
  </body>
</html>
Comment

HTML Comment

<!-- this is a comment -->
<!--
  Or you can comment out a large number of lines.
-->
Paragraph

Paragraph

See: The Paragraph element

<p>I'm from DevMarks</p>
<p>Share quick reference cheat sheet.</p>
HTML link

HTML link

See: The <a> Attributes

hrefThe URL that the hyperlink points to
relRelationship of the linked URL
targetLink target location: _self, _blank, _top, _parent
Image Tag

Image Tag

See: The Image Embed element

<img loading="lazy" src="https://xxx.png" alt="Describe image here" width="400" height="400">
srcRequired, Image location (URL | Path)
altDescribe of the image
widthWidth of the image
heightHeight of the image
loadingHow the browser should load

HTML5 Tags

Document

Document

<body>
  <header>
    <nav>...</nav>
  </header>
  <main>
    <h1>DevMarks</h1>
  </main>
  <footer>
    <p>©2023 DevMarks</p>
  </footer>
</body>
Header Navigation

Header Navigation

<header>
  <nav>
    <ul>
      <li><a href="#">Edit Page</a></li>
      <li><a href="#">Twitter</a></li>
      <li><a href="#">Facebook</a></li>
    </ul>
  </nav>
</header>
HTML5 Video

HTML5 Video

↳ Preview

<video controls width="100%">
  <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
  Sorry, your browser doesn't support embedded videos.
</video>
HTML5 Audio

HTML5 Audio

↳ Preview

<audio controls>
  <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3">
  Your browser does not support the audio element.
</audio>
HTML5 Tags

HTML5 Tags

articleContent that’s independent
asideSecondary content
audioEmbeds a sound, or an audio stream
bdiThe Bidirectional Isolate element
canvasDraw graphics via JavaScript
dataMachine readable content
datalistA set of pre-defined options
detailsAdditional information
dialogA dialog box or sub-window
embedEmbeds external application
figcaptionA caption or legend for a figure
figureA figure illustrated
footerFooter or least important
headerMasthead or important information
mainThe main content of the document
markText highlighted
meterA scalar value within a known range
navA section of navigation links
outputThe result of a calculation
pictureA container for multiple image sources
progressThe completion progress of a task
rpProvides fall-back parenthesis

HTML Tables

Table Example

Table Example

<table>
  <thead>
    <tr>
      <td>name</td>
      <td>age</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Roberta</td>
      <td>39</td>
    </tr>
    <tr>
      <td>Oliver</td>
      <td>25</td>
    </tr>
  </tbody>
</table>
HTML Table Tags

HTML Table Tags

See: td#Attributes

<table>Defines a table
<th>Defines a header cell in a table
<tr>Defines a row in a table
<td>Defines a cell in a table
<caption>Defines a table caption
<colgroup>Defines a group of columns
<col>Defines a column within a table
<thead>Groups the header content
<tbody>Groups the body content
<tfoot>Groups the footer content
<td> Attributes

<td> Attributes

See: td#Attributes

colspanNumber of columns a cell should span
headersOne or more header cells a cell is related to
rowspanNumber of rows a cell should span
<th> Attributes

<th> Attributes

See: th#Attributes

colspanNumber of columns a cell should span
headersOne or more header cells a cell is related to
rowspanNumber of rows a cell should span
abbrDescription of the cell's content
scopeThe header element relates to

HTML Lists

Unordered list

Unordered List

See: The Unordered List element

<ul>
  <li>I'm an item</li>
  <li>I'm another item</li>
  <li>I'm another item</li>
</ul>
Ordered list

Ordered List

See: The Ordered List element

<ol>
  <li>I'm the first item</li>
  <li>I'm the second item</li>
  <li>I'm the third item</li>
</ol>
Definition list

Definition List

See: The Description List element

<dl>
  <dt>A Term</dt>
  <dd>Definition of a term</dd>
  <dt>Another Term</dt>
  <dd>Definition of another term</dd>
</dl>

HTML Forms

Form tags

Form Element

The HTML <form> element is used to collect and send information to an external source.

<form method="POST" action="api/login">
  <label for="mail">Email: </label>
  <input type="email" id="mail" name="mail" />
  <br/>
  <label for="pw">Password: </label>
  <input type="password" id="pw" name="pw" />
  <br/>
  <input type="submit" value="Login" />
  <br/>
  <input type="checkbox" id="ck" name="ck" />
  <label for="ck">Remember me</label>
</form>
Form Attribute

Form Attributes

nameName of form for scripting
actionURL of form script
methodHTTP method, POST / GET (default)
enctypeMedia type, See enctype
onsubmitRuns when the form was submit
onresetRuns when the form was reset
Label tags

Label Tags

for in a label references an input's id attribute

<!-- Nested label -->
<label>Click me
  <input type="text" id="user" name="name"/>
</label>

<!-- 'for' attribute -->
<label for="user">Click me</label>
<input id="user" type="text" name="name"/>
Input tags

Input Text Field

See: HTML input Tags

<label for="Name">Name:</label>
<input type="text" name="Name" id="" />
Textarea tags

Textarea Tags

Textarea is a multiple-line text input control

<textarea rows="2" cols="30" name="address" id="address"></textarea>
Radio Buttons

Radio Buttons

<input type="radio" name="gender" id="m" />
<label for="m">Male</label>
<input type="radio" name="gender" id="f" />
<label for="f">Female</label>
Checkboxes

Checkboxes

<input type="checkbox" name="s" id="soc" />
<label for="soc">Soccer</label>
<input type="checkbox" name="s" id="bas" />
<label for="bas">Baseball</label>
Select tags

Select Tags

<label for="city">City:</label>
<select name="city" id="city">
  <option value="1">Sydney</option>
  <option value="2">Melbourne</option>
  <option value="3">Cromwell</option>
</select>

HTML Media

Image

Image

See: The Image element

<img src="" alt="" />
Audio

Audio

See: The Audio element

<audio src="" controls></audio>
Video

Video

See: The Video element

<video src="" controls></video>