HTML Elements and Nesting
What Is It?
An element tells the browser what a piece of content is. Nesting means putting one element inside another.
What the Tags Mean
p: a paragraph.strong: important words.br: a line break; it has no closing tag.
Example 1
Save each example as index.html and open it in your browser. Each code block is a complete page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Elements and Nesting</title>
</head>
<body>
<p>I am learning <strong>HTML</strong>.</p>
</body>
</html>Browser preview
What you see: You see a sentence. HTML is usually bold because it is inside strong.
Example 2: Another Use
Use nesting to put a link inside a paragraph.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Elements and Nesting</title>
</head>
<body>
<p>Read the <a href="#notes">notes</a>.</p>
<h2 id="notes">My notes</h2>
</body>
</html>Browser preview
Simple Tip
Close the inner tag first: strong closes before p in the first example.
Try It Yourself
Put your own name inside strong.