Altcademy - a Forbes magazine logo Best Coding Bootcamp 2023

How to add a footer in HTML

Getting Started

When you are building a website, the footer is an essential part that resides at the bottom of the page. It's like the closing remarks of a presentation or the last page of a book. In this blog post, we will explore how to add a footer to an HTML page.

In web design, a footer is a section located at the bottom of a page that traditionally contains information like contact details, copyright notices, and links to privacy policies. Imagine it as the basement of a house, where you store things that don't necessarily fit into the main areas, but are still important.

HTML, or HyperText Markup Language, uses 'tags' to mark the start and end of an element. These tags are like containers, holding the content for that specific section.

In HTML5, a new tag was introduced specifically for footers: <footer>. This tag tells the browser, "Hey, everything between these tags is a footer!"

Here's a basic example:

<footer>
    This is a footer!
</footer>

A footer is not much use without some content. Let's add some text inside our <footer> tag.

<footer>
    Copyright © 2022 MyFirstWebsite
</footer>

Just like a house basement, we want to organize the content in our footer. For this, we can use other HTML tags inside the footer tag. Let's add some links using the <a> tag.

<footer>
    <a href="about.html">About Us</a> |
    <a href="contact.html">Contact Us</a> |
    <a href="privacy.html">Privacy Policy</a>
    <p>Copyright © 2022 MyFirstWebsite</p>
</footer>

In the code above, we have added three links: "About Us", "Contact Us", and "Privacy Policy". The '|' symbol is used as a separator between the links. The <p> tag is used to create a new paragraph for the copyright text.

Our footer is functional but doesn't look very appealing. Here's where CSS (Cascading Style Sheets) comes in. It's like the paint and decor for our basement. CSS is a language used for describing the look and formatting of a document written in HTML.

Let's add some basic CSS to our footer. We can include the CSS right in our HTML file using the <style> tag.

<style>
footer {
    background-color: #f2f2f2;
    padding: 10px;
    text-align: center;
}
</style>

This CSS code does three things:

  • Sets the background color of the footer to a light grey (#f2f2f2 is a color code).
  • Adds some padding around the content in the footer. Padding is like adding a cushion around your content to give it some space.
  • Centers the text inside the footer.

Conclusion

Creating a footer in HTML is as simple as using the <footer> tag and filling it with the information you want to display. You can further style and format your footer with CSS. Remember, a well-structured and informative footer can improve the user experience of your website, just like a well-organized basement can enhance a house.

As you continue learning programming and web development, you'll come to see that there are many ways to create and style a footer. This blog post provides a simple and straightforward way to get started. Don't be afraid to experiment with different styles and approaches as you grow more comfortable with HTML and CSS.