Why do 404 pages include inline CSS [closed]
Asked Answered
I

2

6

I see that most 404 pages (in Html5BoilerPlate for instance) have their CSS included in the page's Html code inside a <style> tag instead of being linked from an external sheet. I'm pretty sure people do this on purpose and has some good reasons behind it but I can't get to figure out why they did this.

Ineptitude answered 31/3, 2014 at 15:58 Comment(2)
Not a programming question, should be posted to HTML5 boilerplate support/forums.Heavyhearted
Actually this is a pure web development question that falls under Html5 best practises. 404 pages are not only found in the Html5BoilerPlate package, it was just an example that made me wonder.Ineptitude
H
11

It's probably so you don't end up with another 404 trying to fetch an external stylesheet — which would be pretty ironic — and thus have an unstyled 404 page.

On a more serious note, you generally don't want any error pages incurring any additional HTTP requests, since they would be essentially a waste of server resources as well as bandwidth. Error pages are places you don't want users ending up, so you want to make sure they have as little impact on your server (and possibly others!) as possible.

Haswell answered 31/3, 2014 at 16:5 Comment(1)
That, and a 404 isn't really worth multiple requests. Also common to see base64 encoded images in the inline CSS.Dou
A
2

This page is being served because something is missing or broken and the risk of the same issue not allowing the 404 page to load it's external css necessitates the inclusion of the styles in the page itself.

Not a required practice, but definitely a good idea.

Acrobat answered 31/3, 2014 at 16:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.