[html5] Abbreviated title tags render a blank background?

Nathan Neff nathan.neff at gmail.com
Mon Apr 11 02:32:00 PDT 2011


Thank you for your detailed explanation.  I was very curious as to the
cause of my problem, and you answered my questions.

Thanks again,
--Nate

On Mon, Apr 11, 2011 at 4:20 AM, Jukka K. Korpela
<jukka.k.korpela at kolumbus.fi> wrote:
> Nathan Neff wrote:
>
>> I have a simple HTML page that has a blank <title> element that's
>> expressed using <title />
>> This is probably incorrect/invalid (x)HTML.
>
> It is invalid in HTML 4.01 and predecessors. It is valid in XHTML 1.0 and
> relatives but not recommended - this shorthand should be used only for
> elements with EMPTY declared contents (i.e. elements that _must_ have empty
> contents by the syntax).
>
> If you add the xmlns attribute as required by XHTML 1.0 and serve the
> document as application/xhtml+xml, then e.g. Firefox 4 correctly processes
> it by the XHTML 1.0 book, treating <title /> as equivalent to
> <title></title>.
>
> So things get rather complicated. The morale is: use <title></title>. Or,
> better still, a title element with suitable contents. (Even test documents
> benefit from it - or you benefit, when you play with minimized windows or
> tabs, showing the title element contents.) In HTML5, you could even omit the
> <title> element altogether, though this is not recommended for general use.
>
>> <html>
>>   <head>
>> <title />
>>   </head>
>>   <body>
>> If you <br />see this body, you're probably not using Chrome or
>> Firefox 4. Chrome and Firefox 4 do not show this text.
>>   </body>
>> </html>
>>
>> Firefox 4 and Google Chrome only render a blank background.
>
> They treat <title /> basically as <title> and all the rest as the contents
> of the <title> element.
>
>> Is this behavior a rule of HTML 5?
>
> As far as I can see (and the parsing rules are somewhat complex, for me at
> least), HTML 5 prescribes processing of <title> element content as raw text
> data, so yes. The element is only closed by an explicit </title> tag. If I'm
> not mistaken, this also applies to XHTML serialization of HTML 5.
>
> --
> Yucca, http://www.cs.tut.fi/~jkorpela/
> _______________________________________________
> Help mailing list
> Help at lists.whatwg.org
> http://lists.whatwg.org/listinfo.cgi/help-whatwg.org
>



More information about the Help mailing list