Reinventing the 404 Error Page
The “404 Page Not Found” error page is something we come across everyday. We all stumbled across those pages. I figured it would be nice to create a cool 404 error page to blend in with every website. I already implemented this in my Ajaxilicious project but I think it’s time to share it. It’s a nice technique and really simple. It’s so simple, I was surprised that nobody was using anything similar on the net. Anyway, let’s head on to the description.
From my point of view, a 404 page would be nice to exist as long as it doesn’t interfere with the website. So I thought a transparent message would be great. A message that floats above the main content and does not affect the layout or anything else. So let’s start with the coding:
The CSS:
#PageNotFound {
cursor: pointer;
position:absolute;
left:0px;
/* Pixels from the top you want your warning message */
top:150px;
text-align: center;
color: #fff;
font-size: 30pt;
font-weight: bold;
/* PNG Image with alpha transparency */
background: url('/common/images/overlay.png') repeat;
width:100%;
/* z-index: Use a really big value so it will always be on top */
z-index:100;
margin: 0 auto;
padding: 5px 0;
}
You also need to edit your .htaccess file. Just add
ErrorDocument 404 /index.php?show404=true
and then in your index add this HTML/PHP code:
< ? if ($show404) { ? >
< div id="PageNotFound" onclick="document.getElementById('PageNotFound').style.display='none';">404 Page Not Found.< br / >Click here to close this < /div >
< ? } ? >
The image used in this example can be found here
This works on Firefox 1.5+ and with a little bit tweaking it can work with MSIE. Since I don’t like MSIE, its ‘filters’ CSS property and its incapability to work with PNGs, I will simply stick to Firefox.
A working example (static HTML) can be found here.
That’s all! Hope you use it wisely!
2 Responses to “Reinventing the 404 Error Page”
Leave a Reply
MaSOn: file poli kali doulia .Den ime sinithismenos na xrisimopio wp alla ta themes sou...
Expressed on 1st of Nov 2007
Manali: what new sowftware should be indroduced in the ipod?
Expressed on 7th of Mar 2007
Rebecca: Cool blog, interesting information... Keep it UP »
Expressed on 1st of Mar 2007
Daniel2: i meant 3.000
Expressed on 23rd of Feb 2007
Daniel2: DANG! you sure doing a good effort, bloody 30,000 pounds!? this i dont see...
Expressed on 23rd of Feb 2007

Nicely done Marios! But I strongly believe that in some cases 404 error pages should provide more information to the eventual user. Consider a misspelled/wrong permalink: useful information could be a list of the posts published on the same date and/or posts with similar title.
That’s a kind of reminder for me, since I haven’t implement it yet in my blog! Irony, huh?
January 18th, 2007 at 4:25 pmHeh, you are so right. A 404 page would also be nice to provide some related links in case the user followed a bad link. Maybe I’ll implement that in here. Thanks
January 27th, 2007 at 10:01 pm