The Wayback Machine - https://web.archive.org/web/20240619065539/https://www.geeksforgeeks.org/how-to-create-404-error-page-in-bootstrap/
Open In App

How to Create 404 Error Page in Bootstrap ?

Last Updated : 29 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Every website encounters errors sometimes, so it becomes important to show these errors in a presentable manner to the users. Creating a custom 404 error page using Bootstrap 5 can enhance the user experience when visitors encounter a page that doesn’t exist.

Below are the types of 404 Error Page we can create in Bootstrap:

Simple 404 Error Page

This HTML page displays a 404 error message for a missing webpage. It utilizes Bootstrap 5.3 for styling, ensuring responsiveness. The page centers the error message vertically and horizontally, featuring a large “404” heading, followed by “Page Not Found,” and a brief apology message explaining the absence of the requested page.

Example: This example shows the above-explained approach.

HTML




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,
                                       initial-scale=1.0" />
    <title>404 Error</title>
    <link href=
          rel="stylesheet" />
    <style>
        body,
        html {
            height: 100%;
        }
    </style>
</head>
 
<body class="d-flex justify-content-center
                 align-items-center">
    <div class="col-md-12 text-center">
        <h1>404</h1>
        <h2>Page Not Found</h2>
        <p>
            Sorry, the page you are looking
            for does not exist.
        </p>
    </div>
</body>
 
</html>


Output:

Screenshot-2024-02-22-164753

Illustrative 404 Error Page

This HTML page features a background image with a text overlay, suggesting the user is lost. It employs Bootstrap 5.3 for styling and responsiveness. The centered content includes a prominent title, a message indicating the absence of the requested page, and a call-to-action button prompting users to return to the homepage.

Example: This example shows the use of the above-explained appraoch.

HTML




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,
                                   initial-scale=1.0" />
    <link rel="stylesheet" href=
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "poppins";
        }
 
        .bg_img {
            background: url(
            height: 400px;
            width: 100%;
            background-repeat: no-repeat;
            background-position: center;
            background-size: contain;
        }
    </style>
    <title>Document</title>
</head>
 
<body>
    <section class="py-5">
        <div class="d-flex justify-content-center
                    align-items-center flex-column
                    text-center w-100">
            <div class="bg_img w-50">
            </div>
            <div>
                <p class="display-4">Looks Like You're Lost</p>
                <p>The page you are looking for not available...</p>
                <a href="#"
                   class="text-white text-decoration-none px-4 py-3
                          bg-success d-inline-block mt-2 rounded">
                    Go to Home
                </a>
            </div>
        </div>
    </section>
</body>
 
</html>


Output:

result

An Illustrative 404 Error Page



Similar Reads

How to add a 404 Error Page in the Express ?
Express.js is a powerful framework for node.js. One of the main advantages of this framework is defining different routes or middleware to handle the client's different incoming requests. In this article, we will discuss how to add a 404 error page i.e not found using the express server. 404 is the status code which means not found in the server. I
1 min read
How to Customize the WordPress 404 Error Page?
A customized 404 page acts as a friendly guide, informing users that the requested page isn't available while offering helpful options to navigate your site. The 404-page error is the broken link of the website means that the page you are looking for is not available on the website, 404 is nothing but it is the code language from the server side th
5 min read
How to create custom 404 page in CodeIgniter ?
We often see the 404 error page while using websites. This error page will encounter only when we navigate to a broken link. In CodeIgniter, it is possible to create a custom 404 page to change the look of the 404 page. So in this article, we will look into how to create the custom 404 error page. In order to create a custom 404 error page, we need
2 min read
Create a 404 page using HTML and CSS
In this article, we will see how to create a 404 page using HTML and CSS. A user when trying to access a URL that doesn't exist or has been moved. Instead of presenting a generic error message a custom 404 page can enhance the user experience and even add a touch of creativity to your website. ApproachCreate a basic HTML structure with a standard t
2 min read
How to test a URL for 404 error in PHP?
Checking if a Webpage URL exists or not is relatively easy in PHP. If the required URL does not exist, then it will return 404 error. The checking can be done with and without using cURL library. cURL: The cURL stands for ‘Client for URLs’, originally with URL spelled in uppercase to make it obvious that it deals with URLs. It is pronounced as ‘see
2 min read
Handling 404 Error in Flask
Prerequisite: Creating simple application in Flask A 404 Error is showed whenever a page is not found. Maybe the owner changed its URL and forgot to change the link or maybe they deleted the page itself. Every site needs a Custom Error page to avoid the user to see the default Ugly Error page. GeeksforGeeks also has a customized error page. If we t
4 min read
History of The 404 Error
HTTP stands for HyperText Transfer Protocol. It is invented by Tim Berners. HyperText is the type of text which is specially coded with the help of some standard coding language called HyperText Markup Language (HTML). HTTP/2 is the successor version of HTTP, which was published on May 2015. HTTP/3 is the latest version of HTTP, which is published
2 min read
How to setup 404 page in angular routing ?
To set up a 404 page in the angular routing, we have to first create a component to display whenever a 404 error occurred. In the following approach, we will create a simple angular component called PagenotfoundComponent. Creating Component: Run the below command to create pagenotfound component. ng generate component pagenotfoundProject Structure:
2 min read
How to Redirect 404 errors to a page in Express.js ?
Express Js is a web application framework based on Node.js web server functionality that helps us to create web servers with lesser complexity and in a well-organized manner. Express provides routing services that help us in creating application endpoints that respond based on the HTTP request method (GET, POST, DELETE, etc) and the requested route
2 min read
How to setup 404 page in React Routing ?
Every Website needs a 404 page if the URL does not exist or the URL might have been changed. To set up a 404 page in the angular routing, we have to first create a component to display whenever a 404 error occurs. In the following approach, we will create a simple react component called PagenotfoundComponent.  Prerequisites:NPM &amp; Node JSReact J
2 min read