You can create many different effects for a website with HTML and CSS. One of the simplest examples is fixing an element in any part of the page during scrolling. In this article, we will explain what a footer is and how to fix it without JavaScript. We will also look at HTML footer examples.
A footer is an element located at the bottom of a website. Sometimes, this element is fixed on the page so that it remains visible during scrolling. The effect is similar to, for example, the chat box on the hostman.com website. When scrolling, it always stays in place.
Next, let’s look at a few clear examples of how to make an HTML footer stick on a page.
We will create a simple site footer as a colored block with a single word.
Step 1. Write HTML code with a large number of paragraphs to demonstrate the fixed element during scrolling:
<html>
<head>
<style>
</style>
</head>
<body>
<h1>A simple example of a sticky footer</h1>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<p>This text is additional</p>
<div class="footer">
<p>Footer</p>
</div>
</body>
</html>
Step 2. Using CSS, we will select the font for the text on the page, set the background color, and configure the element's positioning:
<style>
body {
font-family: PT Astra Sans;
background-color: #e9e9f0;
}
.footer {
background-color: #2e34e5;
position: fixed;
right: 0;
bottom: 0;
text-align: center;
width: 99%;
font-size: 19px;
font-weight: bold;
color: #fafaff;
}
</style>
As a result, we’ll have a blue footer on the site that always stays at the bottom during scrolling. This text-containing element will span the full width of the window.
How can you create a site footer with links to external resources? We'll explain this in the second example: the links will point to images from a free stock photo site.
Step 1. Add links to three different images so that we can include them in the HTML footer:
<html>
<head>
<style> </style>
</head>
<body>
<h2>An example of a sticky footer with links to images</h2>
<div class="wrapper">
<div class="footer">
<p class="text">
<a href="https://images.unsplash.com/photo-1483728642387-6c3bdd6c93e5?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=876&q=80" class="menu">Pic1</a>
<a href="https://images.unsplash.com/photo-1570092178365-4cd46034bb19?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1032&q=80" class="menu">Pic2</a>
<a href="https://images.unsplash.com/photo-1604231751678-3f2b03928c10?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80" class="menu">Pic3</a>
</p>
</div>
</div>
</body>
</html>
Step 2. Using CSS, we will configure the site dimensions and the footer with three links:
.wrapper {
height: 1111px;
}
.footer {
background-color: #aac5fa;
position:fixed;
right:0;
bottom:0;
width:99%;
height: 101px;
}
.text {
float:none;
font-size:29px;
word-spacing:40px;
padding-left:29px;
}
</style>
Step 3. Let’s make it so that the text size and background color change when hovering over the links.
<style>
a:active {
text-decoration: none;
}
a:link {
text-decoration: none;
}
a.menu:hover {
font-size:29px;
background-color:#8eff8c;
}
</style>
Now let’s look at how to create an HTML site footer with image links to two popular websites. We won't need the <footer>
tag.
Step 1. Write the code with a large paragraph, add icons for Facebook and Twitter, and include links to their websites.
<html>
<head>
<style></style>
</head>
<body>
<div id="wrapper">
This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling. This text is simply included to show how the footer will move during scrolling.
</div>
<div id="footer">
<div class="all-symbols">
<a href="https://facebook.com/"><img src="https://cdn-icons-png.flaticon.com/256/20/20837.png" class="symbol" alt="FB icon"></a>
<a href="https://x.com/"><img src="https://cdn-icons-png.flaticon.com/256/5969/5969020.png" class="symbol" alt="TW icon"></a>
</div>
</div>
</body>
</html>
Step 2. Use CSS to stick the footer at the bottom of the page and configure the colors and other parameters. The page background will be gray, and the background of the element with icons will be blue.
<style>
#wrapper {
margin: 344 auto 433px;
width: 399px;
}
body {
background-color: e2e1eb;
}
#footer {
background-color: #301fed;
position: fixed;
left: 0;
bottom: 0;
height: 70px;
padding-left: 29px;
color: #f3f2ff;
width: 99%;
}
.all-symbols {
float:left;
margin-top:19px;
padding-left:199px;
}
.symbol {
color: #fffcfc;
margin-top:6px;
margin-left:29px;
height:29px;
}
</style>
Step 3. Now make it so that the background color turns white when hovering over the icons:
<style>
.symbol:hover {
padding:2px;
background-color:#fffcfc;
}
</style>
As a result, we will have a page where the footer contains Facebook and Twitter icons that link to their respective sites.
Let’s now look at how to make an HTML footer stick at the bottom of the page with an unusual effect. The block will be hidden beneath the page; to reveal it, users must interact with another element. In this case, that element will be a red dashed square.
Step 1. Add many paragraphs to the HTML code. This makes it easier to test the footer's fixation on the page:
<style> </style>
<h1>To find the footer, hover your cursor over the red square.</h1>
<h2><p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p><p>A simple paragraph is for example here.</p></p></h2>
<div class="wrapper">
<div class="footer">
<div id="button"></div>
<div id="block">
<div id="text">
<div class="footer1">
<h1>Hidden footer</h1>
</div>
</div>
</div>
</div>
Step 2. Next, add the following CSS code to define the background, footer, and other parameters. We’ll use the PT Astra Sans font; the background will be light blue.
<style>
.wrapper {
height: 1111px;
}
body{
background-color:#8f85ff;
font-family: PT Astra Sans;
text-align:center;
color:#e8e6fc;
}
.footer #block{
position:relative;
margin-top:2px;
width:99,99%;
height:99%;
background: #120f2b;
}
.footer #text{
Position: relative;
right:201px;
width:123px;
margin:14 auto;
top:-51px;
}
.footer1{
float:left;
width:499px;
}
.footer h1{
color: #ffc9c9;
font-family: PT Astra Sans;
margin-top:69px;
margin-left:39px;
}
</style>
Step 3. Create the red square, which will reveal the hidden block. Using the dashed value, make the object dashed to make it stand out even more.
<style>
…
.footer #button{
width:50px;
height:50px;
border: #d41542 8px dashed;
margin:-3 auto;
position:center;
}
.footer #button:hover{
width:50px;
height:50px;
border: #d41542 8px dashed;
}
.footer {
position: fixed;
right:0;
bottom:0;
width: 99%;
height: 2em;
overflow:hidden;
transition: all 2s ease;
}
.footer:hover {
transition: all 2s ease;
height: 9em;
}
…
</style>
The result will be a page where the hidden CSS footer smoothly appears and disappears at any scrolling point. We can apply this effect to any part of the page. The footer only appears when the cursor hovers over the bottom of the window.
We reviewed four ways to stick an HTML footer on a site. The following CSS properties and values were particularly useful:
position: fixed;
right: 0;
bottom: 0;
Instead of text and links, you can include a site search form or a request for clients to leave their contact information in the footer. However, large blocks like these may interfere with page viewing. In such cases, the method in Example 4 can be helpful: creating a small element to hide the HTML footer.
Check out our reliable and high-performance WordPress hosting solutions for your websites.