This page will walk you through some basic examples in HTML. Don't worry if some of the tags look new β you'll get familiar with them as you practice.
<html>
, <head>
, and <body>
.
All web pages are built on a basic structure:
<!DOCTYPE html> <html> <body> <h1>Welcome Message</h1> <p>This is a sample paragraph.</p> </body> </html>
<!DOCTYPE>
Do?The <!DOCTYPE html> line tells the browser to use HTML5. It only appears once β right at the top of the page.
HTML provides six heading levels, from most important (<h1>
) to least important (<h6>
):
<h1>Main Title</h1> <h2>Subheading</h2> <h3>Section Heading</h3>
Paragraphs are written using the <p>
tag:
<p>This is one paragraph.</p> <p>This is another paragraph.</p>
To add a link, use the <a>
tag with the href
attribute:
<a href="https://example.com">Visit Example</a>
href
, src
, and alt
give extra info about HTML elements. You'll learn more about them soon.
To embed an image, use the <img>
tag along with attributes:
<img src="photo.jpg" alt="Description" width="300" height="200">
If you're curious about how a webpage works behind the scenes: