Вопрос

I'm in the process of applying a "HTML4.5" approach to an existing XHTML1.0 Strict site. The idea is to change the doctype and apply semantic classes matching the new elements of HTML5 (<div class="aside">, etc.) and do all that I can get away with, without Internet Explorer(IE) breaking (e.g. applying new <input> type attributes).

The only problem I've encountered is that W3C's validator doesn't like &nbsp; or &copy;, while html5.validator.nu has no problem.

I know that HTML5 validators are experimental at this stage. Should I replace &nbsp; with something? If so, what?

My charset on this particular site is UTF-8.

Это было полезно?

Решение

&nbsp; is fine in the text/html HTML5 and it validates for me at W3.

Where it won't validate is in XHTML5. The only built-in entities in XML are &amp;, &lt;, &gt;, &quot; and &apos;. XHTML1 brought in the HTML entity list by means of the DTD referenced by <!DOCTYPE>, but (X)HTML5 no longer uses a DTD, so that means in the XML serialisation you can't use the HTML entities.

A character reference such as &#xA0; is still okay. And if you're serving your page in the right encoding you can just include a U+00A0 No-Break Space character directly without escaping:  . (Of course that's going to be annoying to edit if your text editor doesn't visually distinguish the no-break and standard space.)

Другие советы

Simply replace all the &nbsp; with &#160;

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top