Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why is it that » valid for an alt atribute but » is not?

share|improve this question
up vote 3 down vote accepted

It depends on your doctype. In HTML 4 and 5, using named entities like » is perfectly valid. However, in XHTML you must use numbered entities like » - most named entities are invalid, except for ", ', <, > and &.

Note: the alt tag is irrelevant in this case, it allows the same textual content as outside of HTML tags.

Simplest solution in my opinion: switch to the HTML5 doctype - <!DOCTYPE html>. It forces standards modes in all browsers, is future proof and is dead simple to remember.

share|improve this answer
Interestingly the site this appeared in is HTML5 – Toby Nov 15 '11 at 15:16
In that case maybe it's a bug in the HTML5 validator; I believe it's still in beta at the moment. HTML5 itself is still changing regularly. – DisgruntledGoat Nov 15 '11 at 15:19
@Toby don't trust what's written behind the hood, trust the specifications. – 발렌탕 Nov 15 '11 at 15:21
I just checked the HTML5 spec for the img element and couldn't see anything specifying the format of alt text. – DisgruntledGoat Nov 15 '11 at 15:25
@Oddant there is an argument though that in practice you need to trust how the browsers implement it - in an ideal world though, yes I would agree. – Toby Nov 15 '11 at 22:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.