Street adress: 1 Rover street
State: N/A
Planet: Mars
Digital home: alexandersandberg.com
<hr>
:<pre>
:Preformatted text will be presented exactly as written in the HTML file.
<blockquote>
:The text inside this blockquote is wrapped in
<p>
tags. Sometimes the quote is really long, and possibly have to occupy multiple lines, but that shouldn't be a problem.
<ol> + <ul> + <li>
:<dl> + <dt> + <dd>
:This is a term
And this is the accompanying description, explaining the above term.
You can also have multiple descriptions (<dt>
), like this one, for each term (<dt>
).
And why not nest lists inside this description?
Another term
With some description.
<figure> + <figcaption>
:Used with an <img>
:
Wholesome Keanu Reeves from placekeanu.com.
Used with a <blockquote>
:
Seek wealth, not money or status. Wealth is having assets that earn while you sleep. Money is how we transfer time and wealth. Status is your place in the social hierarchy.
Naval Ravikant (@naval) on Twitter.
<main>
:See the main content of this page for a use case of <main>
.
<div>
:This paragraph of text is contained inside a <div>
. The element really has no special meaning, other than grouping content together, and should be used as a last resort when no other element is suitable.
Elements: <a>
, <em>
, <strong>
, <small>
, <s>
, <cite>
, <q>
, <dfn>
, <abbr>
, <ruby>
, <rb>
, <rt>
, <rtc>
, <rp>
, <data>
, <time>
, <code>
, <var>
, <samp>
, <kbd>
, <sub>
, <sup>
, <i>
, <b>
, <u>
, <mark>
, <bdi>
, <bdo>
, <span>
, <br>
, <wbr>
<a>
:Here is a link inside a paragraph of text. Below you can find a list of links with different href
attributes.
href
attributehref
attribute<em> + <i> + <strong> + <b>
:The <em>
element represents stress emphasis of its contents. Meanwhile, <i>
is since HTML5 used for text in an alternative voice or mood, or otherwise offset from the normal prose, as you may define it.
If you want to draw attention to some text, feel free to use <b>
. However, if you want to mark the importance of something, you should use <strong>
.
<small> + <u> + <mark> + <s>
:When you want your text to represent small print, use <small>
.
In most cases, there's a better element than <u>
to use, but it can be useful for labelling msispelt text. Avoid using it, however, where the text could be confused for a hyperlink.
You can highlight text for reference purposes with <mark>
, or if the contents is ~no longer accurate or relevant~, wrap it with <s>
.
<abbr> + <dfn>
:By wrapping an abbreviation like CSS in both <dfn>
and <abbr>
, we define the term. This can later be used only using <abbr>
, since we already defined CSS once before.
<q> + <cite> + <data> + <time>
:When citing creative work, include the reference with a <cite>
element. www.w3.org explains that A citation is not a quote (for which the <q>
element is appropriate) instead, like used here.
If you want to link content with a machine-readable translation, use <data>
with a value
attribute. However, if this data is a time- or date-related, like the date July 4, you have to use <time>
together with the datatime
attribute.
<code> + <var> + <samp> + <kbd> + <sub> + <sup>
:When sharing code-snippets, make sure to use the <code>
element. This can be done both display: inline;
, as well as block-level:
* {
color: rebeccapurple;
background: aliceblue;
}
Variables should be surrounded by <var>
, or x amount of people might be confused.
Sample or quotes output are represented with <samp>
: Your expression '1 + 1' equals 2.
To represent user input, like the shortcut Cmd + R on macOS, use <kbd>
.
If you want to subscript or superscript text, use <sub>
or <sup>
.
<bdi> + <bdo> + <ruby> + <rb> + <rt> + <rtc> + <rp>
:Consider using <bdi>
when working with bidirectional content, like the names Alexander and علي.
If you need to override the bidirectional algorithm for some content and its children, use <bdo>
:
Don't forget to specify the dir
attribute!
I said, don't forget to specify the dir
attribute!
Some use of <ruby>
and its related elements:
漢 (Kan) 字 (ji)
旧金山jiùjīnshānSan Francisco
More information about the explanation and usage of these can be read here on www.w3.org.
<span> + <br> + <wbr>
:A <span>
can be used to mark up inline text for various uses, here to make the text bolder.
If you have really long text you might want to insert a
blank line with the <br>
element. You can also insert word breaking opportunities using <wbr>
, to help the browser break long words like Pneumonoultramicroscopicsilicovolcanoconiosis.
Elements: <ins>
, <del>
<ins> + <del>
:If you make a ~really huge~ mistake, you can always go back and fix it later. And don't forget to learn from your mistake.
Both <ins>
and <del>
can be block-level, like this.
~
Here's a block-level paragraph removal.
~
Elements: <picture>
, <source>
, <img>
, <iframe>
, <embed>
, <object>
, <param>
, <video>
, <audio>
, <track>
, <map>
, <area>
, <math>
, <svg>
<img> + <svg>
:This is a fallback message. If you see this, your browser does not support inline SVG.
<picture> + <source>
:A different image will be shown depending on viewport size.
<iframe>
:<embed>
:<object> + <param>
:<video> + <audio> + <track>
:This is a fallback text. If you see this, your browser does not support embedded audio.
Audio is from an example on MDN.
This is a fallback text. If you see this, your browser does not support embedded videos.
Video and subtitles are from an example on MDN.
<map> + <area>
:Each side of the image below is linked to different anchors on this page. Give it a try!
<math>
:The quadratic formula is:
x \= - b ± b 2 - 4 a c 2 a
Elements: <table>
, <caption>
, <colgroup>
, <col>
, <tbody>
, <thead>
, <tfoot>
, <tr>
, <td>
, <th>
<table> + <caption> + <colgroup> + <col>+ <tbody> + <thead> + <tfoot> + <tr> + <td> + <th>
:--- | --- | --- | --- | This is the table caption | <thead> | 2nd colgroup | 2nd colgroup | 3rd colgroup | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<tbody> | This is a cell spanning two columns | Last column | |||||||||||
<tfoot> | Cell 2 | Cell 3 | Cell 4 |
A test page containing most of the HTML5 elements that you'll ever need. Useful for testing CSS resets or CSS frameworks.
HTML5 elements tester by Alexander Sandberg.