Altcademy - a Forbes magazine logo Best Coding Bootcamp 2023

How to code a website in HTML

Understanding The Structure of a Web Page

Think of a web page as a house. The same way that a house has different rooms for different purposes, a web page has different sections like the header, footer, main content area, and sidebars. In HTML, these are defined using 'tags'. A tag is like a label that tells the browser which part of the house (web page) it is.

Here is a basic structure of a web page:

<!DOCTYPE html>
<html>
<head>
    <title>Page Title</title>
</head>
<body>
    <h1>This is a Heading</h1>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
</body>
</html>

In this example, the <html> tag is like the plot of land where the house is built. The <head> tag is like the attic where we store information that isn't immediately visible, like the title of the web page. The <body> tag is where we build the rooms for our content. The <h1> and <p> tags are like labels on the rooms.

Building Your First Room: The Header

The header is like the entrance of your house. It's often the first thing that people see and it usually contains things like the website logo, the main navigation menu, and sometimes a call to action.

Here's how to create a simple header:

<header>
    <h1>This is the header</h1>
    <nav>
        <a href="#">Home</a> | 
        <a href="#">About</a> | 
        <a href="#">Contact</a>
    </nav>
</header>

In this example, the <header> tag defines the header section. The <h1> tag creates a heading. The <nav> tag is used to define navigation links, and the <a> tag is used to create links.

Creating The Main Content Area

The main content area is like the living room. It's where your visitors spend most of their time. This is where you put the content that you want your visitors to read, see, or interact with.

Here's how to create a main content area:

<main>
    <article>
        <h2>This is the article title</h2>
        <p>This is the article content.</p>
    </article>
</main>

In this example, the <main> tag tells the browser that this is the main content area. The <article> tag is used to contain an independent piece of content that makes sense on its own, like a blog post, a news story, or a forum post.

The footer is like the basement. It's at the bottom and it usually contains information like copyright notices, links to privacy policies, and contact information.

Here's how to create a footer:

<footer>
    <p>Copyright © 2022 My Website</p>
</footer>

In this example, the <footer> tag defines the footer section.

Wrapping It Up

HTML is a language that allows us to describe the structure of a web page in a way that a browser can understand. Each part of the page is defined by tags, which are like labels that tell the browser what that part of the page is.

By understanding the basic structure of a web page and how to use tags, you can start building your own web pages. Remember, the best way to learn is by doing. So, start building your web page now!

I hope this blog post has helped you understand how to code a website in HTML. Happy coding!