20.3. HTML Tags¶
Time to dive into learning about all the different tags for creating content! This page contains a helpful table of tags to know for beginning programmers to bookmark. This is by no means an exhaustive list of all HTML tags, but it is a good place to start.
20.3.1. Tags to Know¶
||When surrounding text, makes that text bold.|
||When surrounding text, makes that text italic.|
||A single line break.|
||Creates a paragraph in text.|
||Makes a section in text.|
||Defines an area of the page.|
||Creates a form for user input.|
||Creates an unordered list.|
||Creates an ordered list.|
||Denotes an element of the list. This tag is used for both ordered and unordered lists.|
||Creates a table on the page.|
|Heading Level One||
||Creates a heading in the text.|
There are multiple headings in HTML going from
h1 is the top-level heading,
h2 is a sub-heading of an
h1, and so on. By default, the headings get progressively smaller as the heading level goes up.
A good rule of thumb is to have only one
h1 in a web page and to not skip a level as you add sub-headings. Resist the temptation to use the heading level to change the size of a given heading. The appearance of a heading should be changed using CSS. We will learn how to do this in the next chapter.
20.3.2. Tag Example¶
Here is an example of a basic web page utilizing some of the tags above with the HTML used to make the site.
1 2 3 4 5 6 7 8 9 10 11
<!DOCTYPE html> <html> <head> <title>Plant-Loving Astronauts</title> </head> <body> <h1>Space Plants Are Cool</h1> <p>NASA discovers that plants can live in <b>outer space</b>. More innovations from this discovery to follow.</p> <!-- add images from NASA of these space plants --> </body> </html>
Programmers can add extra information beyond element type to HTML tags. Programmers add attributes to HTML tags for further specification about the element's appearance. Examples of attributes include the alignment of the element or alternate text to an image.
Programmers add attributes before the closing bracket in the opening tag, like so:
<element attribute = "value">content</element>
20.3.4. Attributes Example¶
Here is an example of a basic web page utilizing some of the tags above and appropriate attributes with the HTML used to make the site.
1 2 3 4 5 6 7 8 9 10 11 12
<!DOCTYPE html> <html> <head> <title>Plant-Loving Astronauts</title> </head> <body> <h1>Space Plants Are Cool</h1> <p>NASA discovers that plants can live in <b>outer space</b>. More innovations from this discovery to follow.</p> <img src = "space-flower.jpg" alt = "Flower floating in space."> <!-- This image was taken by NASA and is in the Public Domain --> </body> </html>
<img> tag has two attributes that you will see a lot.
src gives the
location of the image that is being used and
alt gives alternate text for
screen reader users. For that reason,
alt should be a concise description
of what is going on in the image.
20.3.5. Check Your Understanding¶
Which tag is used to make text italicized?