HTML Tags: The Basics

These are the most common HTML tags. You would put these inside <body>, since they correspond to the content of your web page.

  • Block-level elements will be placed in their own line
  • Inline elements will flow in-line with the surrounding text
TagTypeDescription
Containers
<div>BlockCreates a generic block-level container
<span>InlineCreates a generic inline container
Common tags
<h1-h6>BlockMarks headers
<p>BlockMarks paragraphs
<hr>BlockInserts a horizontal ruler
<br>InlineInserts a line break
<a>InlineCreates anchors/hyperlinks
<b>InlineMakes text bold
<i>InlineMakes text italic
<u>InlineMakes text underlined
<s>InlineRenders text with strikethrough
<sub>InlineRenders text as subscript
<sup>InlineRender text as superscript

<div> and <span>

<div> is used to create a generic block-level container, which means it will take the whole horizontal space of its parent (it will be on its new line).

<span> is used to create a generic inline container, which means it will flow with the current line of text.

These containers by themselves will not change how the content is displayed; you will normally use this for layouting and styling with CSS.

| LIVE PREVIEW
I'm creating a new line!
Lorem ipsum I'm flowing with the text dolor sit amet

<h1> <h6>

These are used to create headers. They are block-level elements.

  • <h1> would normally be used for title
  • <h2> would be for the subtitle
  • <h3> would be for the sub-subtitle
  • so on and so forth.
| LIVE PREVIEW

H1: Nice title

H2: Nice sub-title

H3: Nice sub-sub-title

<p>

Marks a paragraph. It's a block-level element.

| LIVE PREVIEW

Lorem ipsum dolor sit amet. Consectetur adipisicing elit.

Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

<hr>

Inserts a horizontal ruler.

| LIVE PREVIEW
one two three
one two three

<br>

Inserts a line break.

| LIVE PREVIEW

Lorem ipsum
dolor sit amet

<a>

Creates anchors and hyperlinks.

Common attributes
  • href=[...] — where the link points to
  • target=[...] — where to open it (read here)
Less common attributes
  • download=[...] — instead of opening the link, prompt the user to download it. If value is not empty, it will be the name of the downloaded file. (Only works for same-origin URLs, or blob: and data: schemes)
  • ping=[...] — list of space-separated URLs to which the browser will send PING POST requests when the hyperlink is followed (usable for tracking).
  • hreflang=[...] — indicates the language of the linked resource (e.g. en-US)
  • rel=[...] — relation of the linked resource (read here)
  • referrerpolicy=[...] read here
| LIVE PREVIEW

To search the internet, click here!

Taken from MDN site: Download an image?

My Anchor

Click here to go to My Anchor

<b>

Makes text bold.

| LIVE PREVIEW
I'm bold!

<i>

Makes text italic.

| LIVE PREVIEW
I'm italic!

<u>

Makes text underlined.

| LIVE PREVIEW
I'm underlined!

<s>

Renders text with strikethrough.

| LIVE PREVIEW
I'm struck-through!

<sub>

Renders text as subscript

| LIVE PREVIEW
I'm a subscript

<sup>

Renders text as superscript

| LIVE PREVIEW
I'm a superscript

References