HTML is like the skeleton of a website. It gives structure to the content on the web. Imagine you're building a house; HTML would be the bricks and beams.
Every HTML file has a basic structure. Here it is:
<!DOCTYPE html>
<html>
<head>
<title>Your Web Page Title</title>
</head>
<body>
<!-- Your content goes here -->
</body>
</html>
<!DOCTYPE html>
: Tells the browser this is an HTML5 document.<html>
: The root element.<head>
: Contains meta information and links.<title>
: Sets the title of your web page.<body>
: Holds the content of your web page.
Here are some commonly used HTML tags:
Headings are used to define titles and subtitles. You have six levels of headings, from <h1>
to <h6>
.
<h1>This is a big heading</h1>
Paragraphs are defined using the <p>
tag.
<p>This is a paragraph.</p>
Links are defined using the <a>
tag.
<a href="https://www.google.com">Visit Google</a>
Images are placed using the <img>
tag.
<img src="image.jpg" alt="A cool image">
You can create lists using <ul>
(unordered) and <ol>
(ordered).
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
HTML tags can have attributes. Attributes provide additional information about an element.
href
: Specifies the URL for a link.src
: Specifies the source URL of an image.alt
: Specifies alternative text for an image.
Example:
<a href="https://www.google.com" target="_blank">Visit Google</a>
Time to create your first web page! Open a text editor on your phone or computer and paste the following code:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>Welcome to my website.</p>
</body>
</html>
Save it as index.html
and open it with a web browser. Ta-da!
Ready to learn more? Check out these free resources: