More HTML Elements
Other elements and tags
As you learn more web development, youāll see tons of other tags.
Hereās a preview of some of the tags youāll encounter. Again - you donāt need to know these ones. Remember that you can look them up later!
Stylized text elements
There are lots of elements for particular kinds of styled text.
Hereās some of the tags, but without examples. Donāt try to memorize them. Instead, skim them, and then remember that you can always go back and look up the right element to use for a particular situation.
List: stylized text elements
<code>
: used to style blocks of code.<pre>
: used for text that has been pre-formatted, like a poem, where the spaces are already there. Otherwise, spaces, tabs, and newlines all get collapsed by the browser.<small>
: Small text<u>
: Underlined text<i>
: Italicized text<s>
: Text with a strikethrough, likethis<q>
: āquoted text that fits within a lineā<blockquote>
: A block quote, usually multiple lines<mark>
: Highlighted text<del>
,<ins>
: Text thatās been deleted or inserted<sub>
,<sup>
: Subscript ($_{subscript}$) and Superscript ($^{superscript}$)
Semantic elements
SemanticsĀ refers to theĀ meaningĀ of a piece of code. Itās about "what purpose or role does that HTML element have", rather than "what does it look like?".
When approaching which markup to use, ask yourself, "What element(s) best describe/represent the data that I'm going to populate?ā
MDN
HTML elements mean something. A <p>
isnāt just styled like a paragraph, it tells other programs that the text inside really is a paragraph.
There are lots of kinds of āthingsā that go on webpages. For many of them, thereās a matching HTML element. Hereās some examples (thereās more than 100!)
List of Semantic Elements
<article>
<section>
<nav>
<footer>
<aside>
<details>
<summary>
Further Exploration: Semantic Elements
https://developer.mozilla.org/en-US/docs/Glossary/semantics
Questions to explore:
- Why use Semantic HTML?
- What are the benefits of Semantic Elements?
- When would you use these?
<div>
, <span>
: Generic Elements
Sometimes, you donāt know which semantic element to use. <div>
stands for ādivisionā and itās a generic block of HTML. <span>
is a generic āspanā of text characters, inline with some other text. If you donāt know another element thatās more appropriate, you can use one of these instead.
See the Pen div and span by Rob Cobb (@rrcobb) on CodePen.
Structure and Page Information
When you create an HTML project, your editor might suggest a bunch of default starter HTML in index.html
. You will usually not need to write these tags yourself, but hereās what they mean in case you were curious.
List: Structure and Page Information tags
<!DOCTYPE html>
isnāt actually an element. It goes at the top of a file to say that itās HTML.<html>
is the āroot elementā of an HTML document. All of the other elements should be inside it.<body>
is where all the page content should go - everything you see on the page.<head>
is hidden metadata. Itās data about the webpage that doesnāt show up on the screen.<title>
is the title of the page. Itās what shows in search results and in the browser tab.<meta>
is for various other metadata about the page. Thereās lots of types, which you can read about on MDN.
Multimedia and Embedding
There are lots of tags for including media on a webpage.
List: Media tags
<iframe>
is for embedding external site content onto a page
<audio>
for an audio recording
<video>
for a video recording
<canvas>
is an element where you can draw shapes programmatically. Used for animations and games!
<object>
is an element for embedded content, like a pdf or a video.
Forms
There is a whole set of HTML tags that are all about forms. Weāll focus on them in Week 3, but hereās the list as a preview:
List: Form tags
<form>
is for creating a form and grouping all the elements inside as part of the form
<input>
represents an input. There are lots of different types of inputs!
<button>
is a button, like a Next or Submit button.
<select>
shows a dropdown
<option>
is for the items in a select dropdown, like <li>
is for items in a list
MDN has several pages on Forms. Weāll learn more in Week 3.
MDN Element Reference
Those are the core elements youāll encounter.
For the full listing of HTML Elements, check out the MDN Elements Reference.
Happy Elementing!