Welcome to a quick tutorial on how to create custom error messages with pure CSS. By now, you should have experienced the intrusive default Javascript alert box. Every time it shows up, users get scared away.
We can create a custom non-intrusive error message with HTML <div>
.
<div style="border: 1px solid darkred; background: salmon">
<i>⚠</i> ERROR!
</div>
Yep, it is that simple. Let us “improve and package” this simple error notification bar so you can reuse it easily in your project – Read on!
ⓘ I have included a zip file with all the source code at the start of this tutorial, so you don’t have to copy-paste everything… Or if you just want to dive straight in.
TABLE OF CONTENTS
DOWNLOAD & NOTES
Firstly, here is the download link to the example code as promised.
QUICK NOTES
If you spot a bug, feel free to comment below. I try to answer short questions too, but it is one person versus the entire world… If you need answers urgently, please check out my list of websites to get help with programming.
EXAMPLE CODE DOWNLOAD
Click here to download the source code, I have released it under the MIT license, so feel free to build on top of it or use it in your own project.
CSS-ONLY ERROR NOTIFICATIONS
Let us start with the raw basics by creating notification bars with just pure CSS and HTML.
1) BASIC NOTIFICATION BAR
1A) THE HTML
1-basic.html
<div class="bar">Plain message</div>
<div class="bar info">Information message</div>
<div class="bar success">Successful message</div>
<div class="bar warn">Warning message</div>
<div class="bar error">Error message</div>
That is actually all we need to create a custom error message, an HTML <div>
with the notification message inside. Take note of the bar
and info | success | warn | error
CSS classes – We will use these to build the notification bar.
1B) THE CSS
error-bar.css
/* (A) THE BASE */
.bar {
padding: 10px;
margin: 10px;
color: #333;
background: #fafafa;
border: 1px solid #ccc;
}
/* (B) THE VARIATIONS */
.info {
color: #204a8e;
background: #c9ddff;
border: 1px solid #4c699b;
}
.success {
color: #2b7515;
background: #ecffd6;
border: 1px solid #617c42;
}
.warn {
color: #756e15;
background: #fffbd1;
border: 1px solid #87803e;
}
.error {
color: #ba3939;
background: #ffe0e0;
border: 1px solid #a33a3a;
}
The CSS is straightforward as well –
.bar
is literally the “basic notification bar” with padding, margin, and border..info | .success | .warn | .error
sets various different colors to fit the “level of notification”.
Feel free to changes these to fit your own website’s theme.
1C) THE DEMO
Plain message
Information message
Successful message
Warning message
Error message
2) ADDING ICONS
2A) THE HTML
2-icon.html
<div class="bar">
<i class="ico">☀</i> Plain message
</div>
<div class="bar info">
<i class="ico">ℹ</i> Information message
</div>
<div class="bar success">
<i class="ico">✔</i> Successful message
</div>
<div class="bar warn">
<i class="ico">⚠</i> Warning message
</div>
<div class="bar error">
<i class="ico">☓</i> Error message
</div>
To add icons to the notification bar, we simply prepend the messages with <i class="ico">&#XXXX</i>
. For those who do not know – That &#XXXX
is a “native HTML symbol”, no need to load extra libraries. Do a search for “HTML symbols list” on the Internet for a whole list of it.
P.S. Check out Font Awesome if you want more icon sets.
2B) THE CSS
error-bar.css
/* (C) ICONS */
i.ico {
display: inline-block;
width: 20px;
text-align: center;
font-style: normal;
font-weight: bold;
}
Just a small addition to position the icon nicely.
2C) THE DEMO
☀ Plain message
ℹ Information message
✔ Successful message
⚠ Warning message
☓ Error message
JAVASCRIPT ERROR NOTIFICATIONS
The above notification bars should work sufficiently well, but here are a few small improvements if you are willing to throw in some Javascript.
3) ADDING CLOSE BUTTONS
3A) THE HTML
3-close.html
<div class="bar">
<div class="close" onclick="this.parentElement.remove()">X</div>
<i class="ico">☀</i> Plain message
</div>
<div class="bar info">
<div class="close" onclick="this.parentElement.remove()">X</div>
<i class="ico">ℹ</i> Information message
</div>
<div class="bar success">
<div class="close" onclick="this.parentElement.remove()">X</div>
<i class="ico">✔</i> Successful message
</div>
<div class="bar warn">
<div class="close" onclick="this.parentElement.remove()">X</div>
<i class="ico">⚠</i> Warning message
</div>
<div class="bar error">
<div class="close" onclick="this.parentElement.remove()">X</div>
<i class="ico">☓</i> Error message
</div>
Not much of a difference here, except that we now add a <div class="close">
that will act as the close button.
3B) THE CSS
error-bar.css
/* (D) CLOSE BUTTON */
.bar { position: relative; }
div.close {
position: absolute;
top: 30%;
right: 10px;
color: #888;
cursor: pointer;
}
There is not much added to the CSS as well. We simply position the close button to the right of the notification bar, and that’s about it.
3C) THE DEMO
4) PACKAGED ERROR NOTIFICATIONS
4A) THE HTML
4-js.html
<!-- (A) LOAD CSS + JS -->
<link href="error-bar.css" rel="stylesheet">
<script src="error-bar.js"></script>
<!-- (B) HTML CONTAINER -->
<div id="demo"></div>
<!-- (C) FOR TESTING -->
<script>
let demo = document.getElementById("demo");
ebar({ target: demo, msg: "Plain" });
ebar({ lvl: 1, target: demo, msg: "Information" });
ebar({ lvl: 2, target: demo, msg: "Success" });
ebar({ lvl: 3, target: demo, msg: "Warning" });
ebar({ lvl: 4, target: demo, msg: "Error" });
</script>
The notification bar is has gotten rather messy, and it is a pain to manually copy-paste them. So why not package everything into an easy-to-use Javascript ebar()
function?
target
Target HTML container to generate the error message.msg
The error or notification message.lvl
Optional, error level.
4B) THE JAVASCRIPT
error-bar.js
function ebar (instance) {
// target : target html container
// msg : notification message
// lvl : (optional) 1-info, 2-success, 3-warn, 4-error
// (A) CREATE NEW NOTIFICATION BAR
let bar = document.createElement("div");
bar.classList.add("bar");
// (B) ADD CLOSE BUTTON
let close = document.createElement("div");
close.innerHTML = "X";
close.classList.add("close");
close.onclick = () => bar.remove();
bar.appendChild(close);
// (C) SET "ERROR LEVEL"
if (instance.lvl) {
let icon = document.createElement("i");
icon.classList.add("ico");
switch (instance.lvl) {
// (C1) INFO
case 1:
bar.classList.add("info");
icon.innerHTML = "ℹ";
break;
// (C2) SUCCESS
case 2:
bar.classList.add("success");
icon.innerHTML = "☑";
break;
// (C3) WARNING
case 3:
bar.classList.add("warn");
icon.innerHTML = "⚠";
break;
// (C4) ERROR
case 4:
bar.classList.add("error");
icon.innerHTML = "☓";
break;
}
bar.appendChild(icon);
}
// (D) NOTIFICATION MESSAGE
let msg = document.createElement("span");
msg.innerHTML = instance.msg;
bar.appendChild(msg);
// (E) ADD BAR TO CONTAINER
instance.target.appendChild(bar);
}
This may look complicated, but this function essentially just creates all necessary notification bar HTML.
4C) THE DEMO
LINKS & REFERENCES
- 6 Ways To Display Messages In HTML JS – Code Boxx
- 2 Ways To Display A Message After Submitting HTML Form – Code Boxx
- 10 Free CSS & JS Notification Alert Code Snippets -SpeckyBoy
- CSS Tips and Tricks for Customizing Error Messages! – Cognito Forms
THE END
Thank you for reading, and we have come to the end. I hope that it has helped you to better understand, and if you want to share anything with this guide, please feel free to comment below. Good luck and happy coding!
Hello Friends, In this article I have listed 35+ Best HTML CSS 404 Page Templates which are available on CodePen.
Best Collection of 404 error page design
#1: 404 Page – Lost In Space
404 Page – Lost In Space, which was developed by Saleh Riaz Qureshi. Moreover, you can customize it according to your wish and need.
Author: Saleh Riaz Qureshi
Created on: April 23, 2018
Made with: HTML, CSS & JS
Tags: 404 Page Lost In Space
#2: 404 SVG animated page concept
404 SVG animated page concept, which was developed by Volodymyr Hashenko. Moreover, you can customize it according to your wish and need.
Author: Volodymyr Hashenko
Created on: October 7, 2016
Made with: HTML & CSS
Tags: 404 SVG animated page concept
#3: Oops! 404 error page template
Oops 404 error page design, which was developed by Israa Adnan. Moreover, you can customize it according to your wish and need.
Author: Israa Adnan
Created on: June 30, 2021
Made with: HTML & CSS
Tags: Oops 404 error page template
#4: Simple 404 page error template
Simple 404 page error template, which was developed by Naved khan. Moreover, you can customize it according to your wish and need.
Author: Naved khan
Created on: June 18, 2018
Made with: HTML & CSS
Tags: Simple 404 page error template
#5: Yeti 404 Page
Yeti 404 Page, which was developed by Darin. Moreover, you can customize it according to your wish and need.
Author: Darin
Created on: August 17, 2018
Made with: HTML, CSS(SCSS) & JS
Tags: Yeti 404 Page
#6: 404 Page UI
404 Page UI, which was developed by Rafaela Lucas. Moreover, you can customize it according to your wish and need.
Author: Rafaela Lucas
Created on: November 27, 2019
Made with: HTML, CSS(SCSS) & JS
Tags: daily ui 404 Page
#7: Fargo 404 page template
Fargo 404 page design, which was developed by Nate Watson. Moreover, you can customize it according to your wish and need.
Author: Nate Watson
Created on: November 18, 2015
Made with: HTML(Pug), CSS(SCSS) & JS
Tags: Fargo 404 page design
#8: GSAP 404 typed message using SplitText
GSAP 404 typed message using SplitText, which was developed by Selcuk Cura. Moreover, you can customize it according to your wish and need.
Author: Selcuk Cura
Created on: October 22, 2017
Made with: HTML, CSS(SCSS) & JS
Tags: GSAP 404 typed message using SplitText
#9: Mars 404 Error Page
Mars 404 Error Page, which was developed by Asyraf Hussin. Moreover, you can customize it according to your wish and need.
Author: Asyraf Hussin
Created on: September 2, 2018
Made with: HTML & CSS
Tags: Mars 404 Error Page
#10: 404 Error Page Template Example
404 Error Page Design, which was developed by Ricardo Prieto. Moreover, you can customize it according to your wish and need.
Author: Ricardo Prieto
Created on: November 4, 2017
Made with: HTML & CSS
Tags: 404 Error Page Design
#11: CSS 404 page template
CSS 404 page template, which was developed by agathaco. Moreover, you can customize it according to your wish and need.
Author: agathaco
Created on: July 28, 2018
Made with: HTML(Pug) & CSS(SCSS)
Tags: CSS 404 page
#12: Error 404 Page not found
Error 404 Page not found, which was developed by Robin Selmer. Moreover, you can customize it according to your wish and need.
Author: Robin Selmer
Created on: August 22, 2017
Made with: HTML & CSS(SCSS)
Tags: Error 404 Page not found
#13: Neon – 404 html template
Neon – 404 html template, which was developed by Tibix. Moreover, you can customize it according to your wish and need.
Author: Tibix
Created on: August 27, 2019
Made with: HTML & CSS(SCSS)
Tags: Neon 404 html template
#14: Sassy page not found template
Sassy page not found template, which was developed by Justin Juno. Moreover, you can customize it according to your wish and need.
Author: Justin Juno
Created on: May 7, 2020
Made with: HTML & CSS(SCSS)
Tags: page not found template
#15: Animated 404 page design html
Animated 404 page design html, which was developed by Jaymie Rosen. Moreover, you can customize it according to your wish and need.
Author: Jaymie Rosen
Created on: October 15, 2017
Made with: HTML, CSS & JS
Tags: Animated 404 page design html
#16: Pure CSS Error Page 404 vampire
Pure CSS Error Page 404 vampire, which was developed by Omar Dsooky. Moreover, you can customize it according to your wish and need.
Author: Omar Dsooky
Created on: August 10, 2017
Made with: HTML & CSS
Tags: Pure CSS Error Page 404 vampire
#17: Simple 404 Error page
Simple 404 Error page, which was developed by vineeth.tr. Moreover, you can customize it according to your wish and need.
Author: vineeth.tr
Created on: April 12, 2016
Made with: HTML & CSS(SCSS)
Tags: Simple 404 Error page
#18: HTML CSS 404 Crying Baby Page Template
HTML CSS 404 Crying Baby Page Template, which was developed by vineeth.tr. Moreover, you can customize it according to your wish and need.
Author: vineeth.tr
Created on: October 12, 2016
Made with: HTML(Pug) & CSS(SCSS)
Tags: HTML CSS 404 Crying Baby Page Template
#19: CSS Train 404 Page
CSS Train 404 Page, which was developed by Carla. Moreover, you can customize it according to your wish and need.
Author: Carla
Created on: November 3, 2018
Made with: HTML & CSS
Tags: CSS Train 404 Page
#20: Pure CSS Animated 404 error page template
Pure CSS Animated 404 error page template, which was developed by Sergio. Moreover, you can customize it according to your wish and need.
Author: Sergio
Created on: March 27, 2018
Made with: HTML & CSS(SCSS)
Tags: Pure CSS Animated 404 error page template
#21: SVG 404 page not found template
SVG 404 page not found template, which was developed by Sylvain Lepinard. Moreover, you can customize it according to your wish and need.
Author: Sylvain Lepinard
Created on: August 9, 2019
Made with: HTML & CSS(SCSS)
Tags: SVG 404 page not found template
#22: Fully responsive 404 page
Fully responsive 404 page, which was developed by Kasper De Bruyne. Moreover, you can customize it according to your wish and need.
Author: Kasper De Bruyne
Created on: February 18, 2020
Made with: HTML, CSS(SCSS) & JS
Tags: Fully responsive 404 page
#23: Responsive custom 404 page
Responsive custom 404 page, which was developed by Ash. Moreover, you can customize it according to your wish and need.
Author: Ash
Created on: September 28, 2017
Made with: HTML & CSS
Tags: Responsive custom 404 page
#24: Wild West 404 Error page Concept
Wild West 404 Error page Concept, which was developed by Zissis Vassos. Moreover, you can customize it according to your wish and need.
Author: Zissis Vassos
Created on: August 26, 2019
Made with: HTML & CSS
Tags: Wild West 404 Error page Concept
#25: html template 404
html template 404, which was developed by Jhey. Moreover, you can customize it according to your wish and need.
Author: Jhey
Created on: March 23, 2020
Made with: HTML(Pug), CSS & JS
Tags: html template 404
#26: Windows 10 style 404 error design
Windows 10 style 404 error design, which was developed by Marco Peretto. Moreover, you can customize it according to your wish and need.
Author: Marco Peretto
Created on: February 8, 2019
Made with: HTML & CSS
Tags: 404 error design
#27: 404 Error Page: Animated SVG GSAP
404 Error: Animated SVG GSAP, which was developed by christine i. Moreover, you can customize it according to your wish and need.
Author: christine i
Created on: February 22, 2020
Made with: HTML, CSS & js
Tags: 404 Error
#28: Custom 404 error page design
Custom 404 error page design, which was developed by Muhammad Rauf. Moreover, you can customize it according to your wish and need.
Author: Muhammad Rauf
Created on: December 3, 2021
Made with: HTML & CSS
Tags: Custom 404 error page design
#29: Oops! page not found template
Oops! page not found template, which was developed by Swarup Kumar Kuila. Moreover, you can customize it according to your wish and need.
Author: Swarup Kumar Kuila
Created on: August 14, 2020
Made with: HTML & CSS
Tags: page not found template
#30: Awesome 404 page not found
Awesome 404 page not found, which was developed by gavra. Moreover, you can customize it according to your wish and need.
Author: gavra
Created on: April 19, 2014
Made with: HTML, CSS & JS
Tags: Awesome 404 page not found
#31: Error 404: Monument Valley inspiration
Error 404: Monument Valley inspiration, which was developed by Sussie Casasola. Moreover, you can customize it according to your wish and need.
Author: Sussie Casasola
Created on: April 29, 2018
Made with: HTML(Pug) & CSS(Sass)
Tags: Error 404
#32: 404 page
404 page, which was developed by Julia. Moreover, you can customize it according to your wish and need.
Author: Julia
Created on: September 7, 2018
Made with: HTML & CSS(Sass)
Tags: 404 page
#33: 404 SVG Error Based Page
404 SVG Error Based Page, which was developed by Dave Pratt. Moreover, you can customize it according to your wish and need.
Author: Dave Pratt
Created on: September 6, 2017
Made with: HTML & CSS(SCSS)
Tags: 404 SVG Error Based Page
#34: bootstrap 404 error page template
bootstrap 404 error page template, which was developed by Aji. Moreover, you can customize it according to your wish and need.
Author: Aji
Created on: June 26, 2021
Made with: HTML & CSS
Tags: bootstrap 404 error page template
#35: Cool 404 error page
Cool 404 error page, which was developed by Anton Lukin. Moreover, you can customize it according to your wish and need.
Author: Anton Lukin
Created on: November 1, 2018
Made with: HTML & CSS
Tags: Cool 404 error page
#36: 404 error template
404 error template, which was developed by Natalia. Moreover, you can customize it according to your wish and need.
Author: Natalia
Created on: January 4, 2021
Made with: HTML & CSS
Tags: 404 error template
Our Awesome Tools
#01: Lenny Face
#02: Fancy Text Generator
This tutorial will show you how to create and customize error messaging for various form elements. In this tutorial, we will customize everything from a basic error message to input field errors and tooltips. The best part? We will be using only CSS for customizations – that means no images or javascript required!
HTML
Below is the markup for the form elements we will be creating error messaging for. This is all of the HTML used throughout this tutorial. Copy and paste this code into your working file:
<!-- Basic Error Message --> <div class="error-message"> <span class="error-text">Checkout could not be completed. Please check your login information and try again.</span> </div> <!-- Input Field Error --> <div class="input-group error"> <label>Password *</label> <input type="text"> <div class="error-message">Password is a required field.</div> </div> <!-- Input Field Error with Tooltip --> <div class="input-group error"> <label>Quantity</label> <input type="text"> <div class="error-tip">Enter a quantity</div> </div>
CSS
Now onto my personal favorite: the CSS. We will keep the basic functionality of the form elements but completely customize their appearance. In the end, they will stand on their own as custom design elements that thoughtfully guide the user through the form process, making it as straightforward and painless as possible.
Basic Error Message
Let’s start with a basic error message. We are going to customize the HTML above to look like this:
This is what we start out with, by default, after adding the HTML:
Customizing a basic error message is really simple. All we have to do is give our text a colored background and a couple font styles using CSS. To style the error message background, add the following styles to your CSS stylesheet:
.error-message { background-color: #fce4e4; border: 1px solid #fcc2c3; float: left; padding: 20px 30px; }
Now let’s style the text itself by adding the following font styles:
.error-text { color: #cc0033; font-family: Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; line-height: 20px; text-shadow: 1px 1px rgba(250,250,250,.3); }
That’s it! Keep reading to learn how to style input field and tooltip errors.
Input Field Error
Now that we have our basic error message styled, let’s work on input field errors. This is what the final product will look like:
And this is what we start out with by default:
First, we want to override the browser’s default styles. Add the following CSS to give your input field a custom look:
/* Basic Input Styling */ .input-group { color: #333; float: left; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 20px; margin: 0 20px 10px; width: 200px; } label { display: block; margin-bottom: 2px; } input[type=text] { background: #fff; border: 1px solid #999; float: left; font-size: 13px; height: 33px; margin: 0; padding: 0 0 0 15px; width: 100%; }
Next, we need to add the styling for the error message that displays when a user does not correctly fill out an input field (i.e. the “This is a required field” message):
.error-message { color: #cc0033; display: inline-block; font-size: 12px; line-height: 15px; margin: 5px 0 0; }
Lastly, add the error-specific styling for the input field elements:
.error label { color: #cc0033; } .error input[type=text] { background-color: #fce4e4; border: 1px solid #cc0033; outline: none; }
Input Field Error with Tooltip
The last element we’re tackling is the tooltip. It is slightly more complicated than the others but well worth the effort. We will also be utilizing Sass nesting to better organize our code, and because we are only using SCSS it is 100% editable and scalable.
Once we are done, the tooltip will look like this:
And by default, this is what we start with after adding the HTML:
First, we override the browser’s default styles with our own custom styling:
/* Basic Input Styling */ .input-group { color: #333; float: left; font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 20px; margin-bottom: 10px; width: 100%; } label { display: block; margin-bottom: 5px; } input[type=text] { background: #fff; border: 1px solid #ccc; color: #333; float: left; font-family: Helvetica, Arial, sans-serif; font-size: 13px; height: 33px; line-height: 20px; margin: 0; padding: 0 0 0 15px; width: 45px; }
Just like our previous example, we need to add the tooltip error message styling that displays when a form error occurs. Note: we are using Sass here to nest the tooltip’s left arrow properties. This comes in handy when trying to keep track of which values are assigned to the tooltip specifically:
/* Tooltip Styling */ .error-tip { background-color: #fce4e4; border: 1px solid #fcc2c3; border-radius: 7px; -moz-border-radius: 7px; -webkit-border-radius: 7px; display: inline; color: #cc0033; float: left; font-weight: bold; line-height: 24px; position: relative; padding: 7px 11px 4px; margin-left: 17px; // Left Arrow Styling Starts Here &:after, &:before { content: ''; border: 7px solid transparent; position: absolute; top: 11px; } &:after { border-right: 7px solid #fce4e4; left: -14px; } &:before { border-right: 7px solid #fcc2c3; left: -15px; } } // end .error-tip
Now all that’s left to do is define the input’s error-specific styling. Again, we will nest these styles under an “error” class selector to make classification and future changes easier:
/* Error Styling */ .error.input-group { label { color: #cc0033; font-weight: bold; } input { border: 2px solid #cc0033; line-height: 37px; outline: none; } .status { display: none; } .error-tip { display: inline; } } // end .error
And that’s it! All the code you need to customize error messaging for default form elements. To experiment with the final results and copy and paste to your heart’s content (without fear of breaking anything), jump on over to Codepen by selecting any of the tutorial links below.
Codepen/Tutorial Links
All: codepen.io/seskew/
Basic Error Message: codepen.io/seskew/pen/akhLx
Input Field Error: codepen.io/seskew/pen/XKJKNQ
Input Field Error with Tooltip: codepen.io/seskew/pen/NrPNBp
Hello readers, Today in this blog you’ll learn how to create a Custom 404 Error Page using only HTML & CSS. Earlier I have shared many blogs related to Web Design like (Responsive Footer Design, Responsive Drop-down Menu, and Responsive Sidebar Menu). But now I’m going to create a 404 Error page which is also a part or section of the Website.
The HTTP 404, 404 Not Found, or 404 Page Not Found error message is a Hypertext Transfer Protocol (HTTP) standard response code, in computer network communications, to indicate that the browser was able to interact with a given server but the server could not locate what was requested. This error displays when the user-requested page or URL doesn’t exist on a particular site.
In this program (Custom 404 Error Page Design), at first, on the webpage, there is a linear-gradient background with a white container box. Inside the box, there is title text, description, and two buttons. That 404 text has a mask animation that means there is gradient-color animation that flows top to bottom. This error page is created only for design purposes and it won’t redirect you to any other page when you click on the buttons.
If you’re feeling difficult to understand what I am saying. You can watch a full video tutorial on this program (Custom 404 Error Page Design).
Video Tutorial of Custom 404 Error Page Design
As you have seen the actual text mask moving animation in the video and I believe you understood the basic codes behind creating this error page. This is a pure CSS program so there are no vast codes used to create this program. Nowadays every website has its custom 404 error page which helps to inform the user about their requested pages are not exist on the website.
You can also create this type of error page and use it on your projects and HTML pages. If you know JavaScript then you can add advanced features to this program and take this program to the next level. If you like this program (Custom 404 Error Page Design) and want to get source codes. You can easily get the source codes of this program. To get the source codes you just need to scroll down.
You might like this:
- Awesome Pagination Design
- Responsive Footer Section Design
- Responsive Sidebar Menu Design
- Responsive Drop-down Menu Bar
Custom 404 Error Page Design [Source Codes]
To create this program (Custom 404 Error Page Design). First, you need to create two Files one HTML File and another one is CSS File. After creating these files just paste the following codes in your file.
First, create an HTML file with the name of index.html and paste the given codes in your HTML file. Remember, you’ve to create a file with .html extension.
<!DOCTYPE html> <!-- Created By CodingNepal --> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>404 Error Page | CodingNepal</title> <link rel="stylesheet" href="style.css"> </head> <body> <div id="error-page"> <div class="content"> <h2 class="header" data-text="404"> 404 </h2> <h4 data-text="Opps! Page not found"> Opps! Page not found </h4> <p> Sorry, the page you're looking for doesn't exist. If you think something is broken, report a problem. </p> <div class="btns"> <a href="https://www.codingnepalweb.com/">return home</a> <a href="https://www.codingnepalweb.com/">report problem</a> </div> </div> </div> </body> </html>
Second, create a CSS file with the name of style.css and paste the given codes in your CSS file. Remember, you’ve to create a file with .css extension.
@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap'); *{ margin: 0; padding: 0; outline: none; box-sizing: border-box; font-family: 'Poppins', sans-serif; } body{ height: 100vh; background: -webkit-repeating-linear-gradient(-45deg, #71b7e6, #69a6ce, #b98acc, #ee8176, #b98acc, #69a6ce, #9b59b6); background-size: 400%; } #error-page{ position: absolute; top: 10%; left: 15%; right: 15%; bottom: 10%; display: flex; align-items: center; justify-content: center; background: #fff; box-shadow: 0px 5px 10px rgba(0,0,0,0.1); } #error-page .content{ max-width: 600px; text-align: center; } .content h2.header{ font-size: 18vw; line-height: 1em; position: relative; } .content h2.header:after{ position: absolute; content: attr(data-text); top: 0; left: 0; right: 0; background: -webkit-repeating-linear-gradient(-45deg, #71b7e6, #69a6ce, #b98acc, #ee8176, #b98acc, #69a6ce, #9b59b6); background-size: 400%; -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 1px 1px 2px rgba(255,255,255,0.25); animation: animate 10s ease-in-out infinite; } @keyframes animate { 0%{ background-position: 0 0; } 25%{ background-position: 100% 0; } 50%{ background-position: 100% 100%; } 75%{ background-position: 0% 100%; } 100%{ background-position: 0% 0%; } } .content h4{ font-size: 1.5em; margin-bottom: 20px; text-transform: uppercase; color: #000; font-size: 2em; max-width: 600px; position: relative; } .content h4:after{ position: absolute; content: attr(data-text); top: 0; left: 0; right: 0; text-shadow: 1px 1px 2px rgba(255,255,255,0.4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .content p{ font-size: 1.2em; color: #0d0d0d; } .content .btns{ margin: 25px 0; display: inline-flex; } .content .btns a{ display: inline-block; margin: 0 10px; text-decoration: none; border: 2px solid #69a6ce; color: #69a6ce; font-weight: 500; padding: 10px 25px; border-radius: 25px; text-transform: uppercase; transition: all 0.3s ease; } .content .btns a:hover{ background: #69a6ce; color: #fff; }
That’s all, now you’ve successfully created a Custom 404 Error Page Design using HTML & CSS. If your code doesn’t work or you’ve faced any error/problem then please comment down or contact us from the contact page.
Hello, guys in this tutorial we will create an simple 404 error page template using HTML & CSS, and also i have listed best 404 page not found examples which is are available in codepen.
How to create 404 page not found template using HTML & CSS
Step 1: — Creating a New Project
The first thing we’ll do is create a folder that will contain all of the files that make up the project. Create an empty folder on your devices and name it “as you want”.
Open up Visual Studio Code or any Text editor which is you liked, and create files(index.html, style.css) inside the folder which you have created for 404 error page. In the next step, we will start creating the basic structure of the webpage.
Step 2: — Setting Up the basic structure
In this step, we will add the HTML code to create the basic structure of the project.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>404 Error Page</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta https-equiv="X-UA-Compatible" content="ie=edge" /> <link rel="stylesheet" href="style.css" /> <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@500&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> </body> </html>
This is the base structure of most web pages that use HTML.
Add the following code inside the <body>
tag:
<div class="wrapper"> <div class="container"> <div class="grid-row"> <div class="colmun colmun-left"> <img src="image-left.png" alt="image-left"> <h1 class="px-spc-b-20">We can't find the page you are looking for.</h1> <span class="px-spc-b-20">This page has been relocated or removed.</span> <button class="go-home"><i class="fa fa-home"></i> Go Home</button> </div> <div class="colmun colmun-right"> <img src="right-shape.png" alt="right-shape"> </div> </div> </div> </div>
Step 3: — Adding Styles for the Classes
In this step, we will add CSS code for style our html elements.
* { padding: 0; margin: 0; outline: 0; color: #444; box-sizing: border-box; font-family: 'IBM Plex Sans', sans-serif; } body { display: flex; align-items: center; justify-content: center; height: 100vh; overflow: hidden; } h1 { font-size: 50px; line-height: 60px; } span { display: block; font-size: 18px; line-height: 30px; } .container { width: 80%; max-width: 1600px; margin: auto; } .grid-row { display: grid; grid-template-columns: 1fr 1fr; place-items: center; grid-gap: 50px; } .colmun-left { text-align: left; } .colmun-right { text-align: right; } .px-spc-b-20 { padding-bottom: 20px; } button.go-home { padding: 5px 20px; background: #ffa000; border: transparent; border-radius: 2px; box-shadow: 0 0 2px rgb(0 0 0 / 30%); cursor: pointer; margin: 20px 0; color: #fff; } button.go-home i { color: #fff; } img { display: block; width: 100%; }
#Final Result
Best Collection of 404 error page design
#1: 404 Page – Lost In Space
404 Page – Lost In Space, which was developed by Saleh Riaz Qureshi. Moreover, you can customize it according to your wish and need.
Author: | Saleh Riaz Qureshi |
Created on: | April 23, 2018 |
Made with: | HTML, CSS & JS |
Demo Link: | Source Code / Demo |
Tags: | 404 Page Lost In Space |
#2: 404 SVG animated page concept
404 SVG animated page concept, which was developed by Volodymyr Hashenko. Moreover, you can customize it according to your wish and need.
Author: | Volodymyr Hashenko |
Created on: | October 7, 2016 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | 404 SVG animated page concept |
#3: Oops! 404 error page template
Oops 404 error page design, which was developed by Israa Adnan. Moreover, you can customize it according to your wish and need.
Author: | Israa Adnan |
Created on: | June 30, 2021 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Oops 404 error page template |
#4: Simple 404 page error template
Simple 404 page error template, which was developed by Naved khan. Moreover, you can customize it according to your wish and need.
Author: | Naved khan |
Created on: | June 18, 2018 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Simple 404 page error template |
#5: Yeti 404 Page
Yeti 404 Page, which was developed by Darin. Moreover, you can customize it according to your wish and need.
Author: | Darin |
Created on: | August 17, 2018 |
Made with: | HTML, CSS(SCSS) & JS |
Demo Link: | Source Code / Demo |
Tags: | Yeti 404 Page |
#6: Daily UI #008 – 404 Page
daily ui 404 Page, which was developed by Rafaela Lucas. Moreover, you can customize it according to your wish and need.
Author: | Rafaela Lucas |
Created on: | November 27, 2019 |
Made with: | HTML, CSS(SCSS) & JS |
Demo Link: | Source Code / Demo |
Tags: | daily ui 404 Page |
#7: Fargo 404 page template
Fargo 404 page design, which was developed by Nate Watson. Moreover, you can customize it according to your wish and need.
Author: | Nate Watson |
Created on: | November 18, 2015 |
Made with: | HTML(Pug), CSS(SCSS) & JS |
Demo Link: | Source Code / Demo |
Tags: | Fargo 404 page design |
#8: GSAP 404 typed message using SplitText
GSAP 404 typed message using SplitText, which was developed by Selcuk Cura. Moreover, you can customize it according to your wish and need.
Author: | Selcuk Cura |
Created on: | October 22, 2017 |
Made with: | HTML, CSS(SCSS) & JS |
Demo Link: | Source Code / Demo |
Tags: | GSAP 404 typed message using SplitText |
#9: Mars 404 Error Page
Mars 404 Error Page, which was developed by Asyraf Hussin. Moreover, you can customize it according to your wish and need.
Author: | Asyraf Hussin |
Created on: | September 2, 2018 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Mars 404 Error Page |
#10: 404 Error Page Template Example
404 Error Page Design, which was developed by Ricardo Prieto. Moreover, you can customize it according to your wish and need.
Author: | Ricardo Prieto |
Created on: | November 4, 2017 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | 404 Error Page Design |
Hello, guys in this tutorial we will create an animated share button using HTML & CSS, and also i have listed best social share button examples which is are available in codepen.
#11: CSS 404 page template
CSS 404 page template, which was developed by agathaco. Moreover, you can customize it according to your wish and need.
Author: | agathaco |
Created on: | July 28, 2018 |
Made with: | HTML(Pug) & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | CSS 404 page |
#12: Error 404 Page not found
Error 404 Page not found, which was developed by Robin Selmer. Moreover, you can customize it according to your wish and need.
Author: | Robin Selmer |
Created on: | August 22, 2017 |
Made with: | HTML & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | Error 404 Page not found |
#13: Neon – 404 html template
Neon – 404 html template, which was developed by Tibix. Moreover, you can customize it according to your wish and need.
Author: | Tibix |
Created on: | August 27, 2019 |
Made with: | HTML & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | Neon 404 html template |
#14: Sassy page not found template
Sassy page not found template, which was developed by Justin Juno. Moreover, you can customize it according to your wish and need.
Author: | Justin Juno |
Created on: | May 7, 2020 |
Made with: | HTML & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | page not found template |
#15: Animated 404 page design html
Animated 404 page design html, which was developed by Jaymie Rosen. Moreover, you can customize it according to your wish and need.
Author: | Jaymie Rosen |
Created on: | October 15, 2017 |
Made with: | HTML, CSS & JS |
Demo Link: | Source Code / Demo |
Tags: | Animated 404 page design html |
#16: Pure CSS Error Page 404 vampire
Pure CSS Error Page 404 vampire, which was developed by Omar Dsooky. Moreover, you can customize it according to your wish and need.
Author: | Omar Dsooky |
Created on: | August 10, 2017 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Pure CSS Error Page 404 vampire |
#17: Simple 404 Error page
Simple 404 Error page, which was developed by vineeth.tr. Moreover, you can customize it according to your wish and need.
Author: | vineeth.tr |
Created on: | April 12, 2016 |
Made with: | HTML & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | Simple 404 Error page |
#18: HTML CSS 404 Crying Baby Page Template
HTML CSS 404 Crying Baby Page Template, which was developed by vineeth.tr. Moreover, you can customize it according to your wish and need.
Author: | vineeth.tr |
Created on: | October 12, 2016 |
Made with: | HTML(Pug) & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | HTML CSS 404 Crying Baby Page Template |
#19: CSS Train 404 Page
CSS Train 404 Page, which was developed by Carla. Moreover, you can customize it according to your wish and need.
Author: | Carla |
Created on: | November 3, 2018 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | CSS Train 404 Page |
#20: Pure CSS Animated 404 error page template
Pure CSS Animated 404 error page template, which was developed by Sergio. Moreover, you can customize it according to your wish and need.
Author: | Sergio |
Created on: | March 27, 2018 |
Made with: | HTML & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | Pure CSS Animated 404 error page template |
#21: SVG 404 page not found template
SVG 404 page not found template, which was developed by Sylvain Lepinard. Moreover, you can customize it according to your wish and need.
Author: | Sylvain Lepinard |
Created on: | August 9, 2019 |
Made with: | HTML & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | SVG 404 page not found template |
#22: Fully responsive 404 page
Fully responsive 404 page, which was developed by Kasper De Bruyne. Moreover, you can customize it according to your wish and need.
Author: | Kasper De Bruyne |
Created on: | February 18, 2020 |
Made with: | HTML, CSS(SCSS) & JS |
Demo Link: | Source Code / Demo |
Tags: | Fully responsive 404 page |
#23: Responsive custom 404 page
Responsive custom 404 page, which was developed by Ash. Moreover, you can customize it according to your wish and need.
Author: | Ash |
Created on: | September 28, 2017 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Responsive custom 404 page |
#24: Wild West 404 Error page Concept
Wild West 404 Error page Concept, which was developed by Zissis Vassos. Moreover, you can customize it according to your wish and need.
Author: | Zissis Vassos |
Created on: | August 26, 2019 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Wild West 404 Error page Concept |
#25: html template 404
html template 404, which was developed by Jhey. Moreover, you can customize it according to your wish and need.
Author: | Jhey |
Created on: | March 23, 2020 |
Made with: | HTML(Pug), CSS & JS |
Demo Link: | Source Code / Demo |
Tags: | html template 404 |
#26: Windows 10 style 404 error design
Windows 10 style 404 error design, which was developed by Marco Peretto. Moreover, you can customize it according to your wish and need.
Author: | Marco Peretto |
Created on: | February 8, 2019 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | 404 error design |
#27: 404 Error Page: Animated SVG GSAP
404 Error: Animated SVG GSAP, which was developed by christine i. Moreover, you can customize it according to your wish and need.
Author: | christine i |
Created on: | February 22, 2020 |
Made with: | HTML, CSS & js |
Demo Link: | Source Code / Demo |
Tags: | 404 Error |
#28: Custom 404 error page design
Custom 404 error page design, which was developed by Muhammad Rauf. Moreover, you can customize it according to your wish and need.
Author: | Muhammad Rauf |
Created on: | December 3, 2021 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Custom 404 error page design |
#29: Oops! page not found template
Oops! page not found template, which was developed by Swarup Kumar Kuila. Moreover, you can customize it according to your wish and need.
Author: | Swarup Kumar Kuila |
Created on: | August 14, 2020 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | page not found template |
#30: Awesome 404 page not found
Awesome 404 page not found, which was developed by gavra. Moreover, you can customize it according to your wish and need.
Author: | gavra |
Created on: | April 19, 2014 |
Made with: | HTML, CSS & JS |
Demo Link: | Source Code / Demo |
Tags: | Awesome 404 page not found |
#31: Error 404: Monument Valley inspiration
Error 404: Monument Valley inspiration, which was developed by Sussie Casasola. Moreover, you can customize it according to your wish and need.
Author: | Sussie Casasola |
Created on: | April 29, 2018 |
Made with: | HTML(Pug) & CSS(Sass) |
Demo Link: | Source Code / Demo |
Tags: | Error 404 |
#32: 404 page
404 page, which was developed by Julia. Moreover, you can customize it according to your wish and need.
Author: | Julia |
Created on: | September 7, 2018 |
Made with: | HTML & CSS(Sass) |
Demo Link: | Source Code / Demo |
Tags: | 404 page |
#33: 404 SVG Error Based Page
404 SVG Error Based Page, which was developed by Dave Pratt. Moreover, you can customize it according to your wish and need.
Author: | Dave Pratt |
Created on: | September 6, 2017 |
Made with: | HTML & CSS(SCSS) |
Demo Link: | Source Code / Demo |
Tags: | 404 SVG Error Based Page |
#34: bootstrap 404 error page template
bootstrap 404 error page template, which was developed by Aji. Moreover, you can customize it according to your wish and need.
Author: | Aji |
Created on: | June 26, 2021 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | bootstrap 404 error page template |
#35: Cool 404 error page
Cool 404 error page, which was developed by Anton Lukin. Moreover, you can customize it according to your wish and need.
Author: | Anton Lukin |
Created on: | November 1, 2018 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | Cool 404 error page |
#36: 404 error template
404 error template, which was developed by Natalia. Moreover, you can customize it according to your wish and need.
Author: | Natalia |
Created on: | January 4, 2021 |
Made with: | HTML & CSS |
Demo Link: | Source Code / Demo |
Tags: | 404 error template |
If you liked this article 20+ Like and Favorite Button Examples, you should check out this one If you 20+ CSS Like Button Examples