Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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
1  
@Toby don't trust what's written behind the hood, trust the specifications. –  Oddant Nov 15 '11 at 15:21
1  
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

 
discard

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.