On a 404 or 403 page, should we include the error code or can the page be written and designed better for UX without it?
While I don't think you need to explicitly display the exact error code, it won't harm to have it. Even those pages using creative "page not found" messages tend to use the error code, especially when this error is 404, because anyone surfing the web for some time has found this error many times, so a lot of people know what a 404 error code is (even if they don't know it's a response code).
On a technical side, it's good to display the error code, because it provides a hint on what to do after getting this error. Obviously, if you 're using just plain Unix messages, this is extremely needed. See the list of HTTP response codes. It's really easy to see not all messages are the same. Even if the outcome may look similar (such as a page not found), some errors offer alternatives, while other errors are definitive.
With the above being said, I think you'll realize something basic: more important than displaying error codes is to explain users what are their options.
Finally, here’s some additional info on error messages:
I always approached this problem similarly to a search that returns no results.
Imagine that you are in a clothing store:
You: "Do you have this sweater in teal?"
Bad salesperson: "No, we don't. Sorry."
Good salesperson: "I'm sorry, we don't have it in teal, but we do have it in Aqua, or this gorgeous blue that I think would really look great with your eyes."
Similarly, if a search returns no results or a page is missing, try to offer them the next best thing to show that you're interested in satisfying them.
Note that the "Good salesperson" doesn't just say "We have it in Aqua, etc." because that would be rude: It ignores the fact that the store doesn't have it in teal. Similarly, a good UI would acknowledge the 404 (or other error), going as far as to show the error number, especially if the page invites feedback from the user. It lets them be specific: "I got a 404 error on your page just now …."
[Edited to add last paragraph on recommendation of commenter.]
In an anecdotal survey of the 404 pages here: http://www.creativebloq.com/web-design/best-404-pages-812505 it seems to me that you certainly don't need to incorporate the code into the page to have an effective/usable/fun 404 page, but many do anyway.
I would think showing the code would have more of an appeal to a power user or technical user (like us!) but I would recommend not having it be as prominent if you expect the general public to stumble across it.
I think it really depends on the error. Errors like
404 defiantly, because
404 is understood nearly universally. It might be better for errors like
401 Unauthorized and
403 Forbidden should be translated into more user friendly messages. For me personally, when I see a big
403 Forbidden I get suspicious and wan to hack around. Thus far, all I have mentioned a
4xx codes which are client errors.
5xx error codes (since they can be very vague) should be translated into a user friendly message. Since these are server errors, the user shouldn't know about them. At my high school, I went to check my grades once, and the server had an internal error (
500) and dumped a bunch of JSP on the screen. Not only was it a potential security concern, but it was generally ugly to look at. So I would say to not worry about the status code in server errors, just give a friendly message like "Hey, currently are servers are experiencing some issues, but we will be back up soon."
p.s. HTTP 418 should always be displayed with the code and default message. ;)