Skip to content

HTML Basics: Building Your First Web Page

5 min read

If you’re just starting your web development journey, HTML (HyperText Markup Language) is the first thing you need to learn. HTML is the backbone of every website, providing structure and content to your web pages. In this beginner’s guide, we’ll walk you through the basics of HTML, covering the fundamental elements like headings, paragraphs, links, and more. By the end, you’ll be able to create a simple webpage from scratch!

What is HTML?

HTML is a markup language used to create the structure of web pages. It’s made up of elements (also called tags) that tell the browser how to display content. For example, headings are marked with <h1>, paragraphs with <p>, and links with <a>.

Setting Up Your First HTML Document

Before we dive into the tags, let’s first set up a basic HTML file.

1. Create an HTML File

To begin, you’ll need to create a new HTML file. Open any text editor (Notepad, VS Code, Sublime Text, etc.) and create a new file. Save it as index.html. The .html extension is essential because it tells the browser that it’s an HTML file.

2. Basic Structure of an HTML Document

Every HTML document follows the same basic structure. Here’s the skeleton of a simple HTML page:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My First Web Page</title>
</head>
<body>
    <!-- Content goes here -->
</body>
</html>

Let’s break this down:

  • <!DOCTYPE html>: This declaration tells the browser that the document is an HTML5 document.
  • <html lang="en">: The opening <html> tag begins the HTML document, and the lang="en" attribute specifies that the content is in English.
  • <head>: The head section contains metadata like the document’s title, character encoding, and other information that isn’t visible on the page itself.
  • <body>: This is where the visible content of your webpage goes. All your headings, paragraphs, and links will be placed inside this section.

Common HTML Tags for Beginners

Now that we’ve set up our basic document structure, let’s explore some of the most common HTML tags.

1. Headings

Headings are used to define the titles and subheadings of your webpage content. HTML has six levels of headings, ranging from <h1> (the most important) to <h6> (the least important).

Example:

<h1>Welcome to My First Web Page</h1>
<h2>About Me</h2>
<h3>My Hobbies</h3>

In this example, <h1> is the main title of the page, while <h2> and <h3> are subheadings that provide structure to the content.

2. Paragraphs

Paragraphs are used to add text content to your page. You define a paragraph with the <p> tag.

Example:

<p>Welcome to my website! I'm excited to share my web development journey with you.</p>

This is how you add a basic paragraph of text to your webpage.

3. Links

Links are an essential part of any webpage. You can link to other pages or external websites using the <a> (anchor) tag. The href attribute specifies the URL of the page you want to link to.

Example:

<a href="https://www.example.com">Visit Example Website</a>

This link will take users to the specified website when they click on it.

4. Images

Images are added to a webpage with the <img> tag. The src attribute specifies the image source (the URL or file path), and the alt attribute provides alternative text if the image can’t be displayed.

Example:

<img src="image.jpg" alt="A beautiful scenery">

This code will display the image image.jpg on your webpage with the alt text “A beautiful scenery.”

Putting It All Together

Now that you know how to use some basic HTML tags, let’s put everything together and create a simple webpage.

Here’s an example of a basic webpage structure:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My First Web Page</title>
</head>
<body>
    <h1>Welcome to My First Web Page</h1>
    <p>Hi! I’m a beginner in web development, and this is my first HTML page. I’m excited to share it with you!</p>
    <h2>About Me</h2>
    <p>I love coding, hiking, and playing video games. I'm currently learning web development to build websites and apps.</p>
    <h3>My Hobbies</h3>
    <ul>
        <li>Coding</li>
        <li>Hiking</li>
        <li>Reading</li>
    </ul>
    <a href="https://www.example.com">Visit My Favorite Website</a>
</body>
</html>

Explanation of the Code:

  • Headings: We used <h1> for the main title and <h2> and <h3> for subheadings.
  • Paragraphs: We used <p> tags to add text content.
  • Unordered List: We used the <ul> and <li> tags to create a list of hobbies.
  • Link: The <a> tag links to an external website.

Conclusion

Congrats! You’ve just learned the basics of HTML and how to create your first simple webpage. With these fundamental tags—headings, paragraphs, links, and images—you can start building more complex web pages as you continue your learning journey.

Next Steps

  • Explore other HTML tags such as tables, forms, and semantic elements like <header>, <footer>, and <article>.
  • Learn about CSS to style your webpage and make it look visually appealing.
  • Start experimenting with JavaScript to add interactivity to your pages.

By mastering HTML, you’ll have the foundation to build any website. The web is full of possibilities, so continue exploring and practicing to create even more dynamic and engaging content!

Leave a Reply

Your email address will not be published. Required fields are marked *

×