By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,404 Members | 1,987 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,404 IT Pros & Developers. It's quick & easy.

XHTML simple little header questions

P: n/a

Re. <title>, my impression has been that a line break is _NOT_ allowed
in the contained text. Is that true? Also, I gather a double quotation
mark in the text string (and ampersand, etc.) _IS_ acceptable, but not
char entities (such as &quote;), decimal characters (such as ‛)
or style-sheet defined elements (such as <q>).

Re. <meta name="description">, is a line break acceptable here? My
impression is that for the enclosed descriptor string, one can't have
illicit characters (such as & and ") nor style-sheet defined elements
(such as <q>, etc.), but only decimal characters in lieu of illicit
characters (such as ‛).

Re. <meta name="keywords">, same question about line breaks. For
XHTML, can one still freely choose either a comma-separated or
space-separated list? Is there any reason to choose one over the
other?

--
Haines Brown
br****@hartford-hwp.com
kb****@arrl.net
www.hartford-hwp.com

Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Haines Brown <br****@teufel.hartford-hwp.com> wrote:
Re. <title>, my impression has been that a line break is _NOT_
allowed in the contained text. Is that true?
No, in element content, a line break is always permitted. It is
equivalent to a space (except within a <pre> or <textarea> element).
Also, I gather a
double quotation mark in the text string (and ampersand, etc.) _IS_
acceptable, but not char entities (such as &quote;), decimal
characters (such as ‛) or style-sheet defined elements (such
as <q>).
The content model of <title> is #PCDATA, parsed character data, which
means that any characters are allowed and entity references (such as
&quot; - note the spelling, &quote; is undefined) and character
references (such as ‛) are allowed, but no elements (such as
<q>) are allowed. The quotation mark " is no problem, whereas the
ampersand & can be, so it is safest to escape it as &amp; unless it is
meant to start an entity or character reference.

However, browsers get this partly wrong. For example, IE 6 on Win98
seems to get ‛ very wrong. I had noticed that it displays –
as a thick vertical bar (effectively as a symbol of undisplayable
character) but with ‛ things get _very_ wrong: if I have
<title>test ‛</title>
then IE ignores the entire <title> element and displays the page's URL
in the browser window's top bar where it normally shows the title.

On ISO-8859-1 encoded pages, ISO-8859-1 characters work well in the
<title> element, though. (Well, apart from the fact that the font used
by the browser there is somewhat inadequate.)
Re. <meta name="description">, is a line break acceptable here?
You mean in the content attribute? That's partly a different thing. In
principle, line breaks are permitted in attribute values and are
equivalent to spaces. In practice, browsers sometimes get this wrong,
and the XHTML 1.0 recommendation says, in the (in)famous appendix C:
"Avoid line breaks and multiple white space characters within attribute
values. These are handled inconsistently by user agents."
As far as I know, this has nothing special to do with XHTML. Rather, it
is based on an observation of browser behavior, which is indeed
inconsistent. But this should be of little importance, since you mainly
write those <meta> tags for search engines, not browsers, and I think
search engines get this simple thing right.

On the other hand, <meta name="description"> is not particularly
important. It is more important to start the _body_ of your document in
an interesting way - in a way that makes human readers immediately
interested and aware of the content and thereby gives good food to
search engines as well.

However, if, for example, a Mozilla user hits control-I on your page,
to view page info, he will see, under the "Meta" heading, a
"description" field. And there the line breaks seem to appear as double
vertical bars - at least on Mozilla 1.4 under Win98. This is somewhat
annoying, so it is best to write the description on one line if you can
afford it (that is, if your authoring tool lets you work conveniently
with long lines).
My
impression is that for the enclosed descriptor string, one can't
have illicit characters (such as & and ") nor style-sheet defined
elements (such as <q>, etc.), but only decimal characters in lieu
of illicit characters (such as ‛).
The content attribute of <meta> is declared as being of type CDATA,
which means (for attributes) effectively the same as #PCDATA. Thus,
entity and character references are OK. Tags are not recognized (but
neither are they errors - this deviates from #PCDATA, but we're getting
rather theoretical here). The quotation mark " is a special case, since
it is used as a delimiter, so inside the attribute value, it needs to
be escaped e.g. as &quot; (if you use " as delimiter - you could use
the apostrophe ' as well). Whether search engines get everything right
is a different matter.
Re. <meta name="keywords">, same question about line breaks.
Ditto. But this <meta> tag is rather useless, since search engines have
largely ignored it for years, due to widespread abuse.
For
XHTML, can one still freely choose either a comma-separated or
space-separated list? Is there any reason to choose one over the
other?


Inside the content attribute in <meta name="keywords" content="...">,
you mean? This is not defined in any specification. There are various
rumors of what search engines actually do, but what sounds most
probable is that commas separate words and phrases, whereas spaces just
separate words _inside_ a phrase. So
content="foo, bar zap, zip zop"
would specify keywords/keyphrases "foo", "bar zap", "zip zop", and this
might be relevant when people use phrase search. But this is just an
educated guess, or maybe just speculation.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #2

P: n/a
"Jukka K. Korpela" <jk******@cs.tut.fi> writes:
Haines Brown <br****@teufel.hartford-hwp.com> wrote:
Re. <title>, my impression has been that a line break is _NOT_
allowed in the contained text. Is that true?


No, in element content, a line break is always permitted. It is
equivalent to a space (except within a <pre> or <textarea> element).

....

Thank you very much; you straightened out a number of points.

--
Haines Brown
br****@hartford-hwp.com
kb****@arrl.net
www.hartford-hwp.com

Jul 20 '05 #3

P: n/a
On Mon, 5 Jan 2004, Jukka K. Korpela wrote:
However, browsers get this partly wrong.
Title bars are typically produced by facilities of the OS and/or the
window manager, so it could be that the browser itself is not at
fault (sometimes it is, sometimes it isn't).
For example, IE 6 on Win98
seems to get ‛ very wrong. I had noticed that it displays –
as a thick vertical bar (effectively as a symbol of undisplayable
character)
I can't speak for Win98 specifically, but I was following some advice
of yours when I found one solution to that class of problem: see
http://ppewww.ph.gla.ac.uk/~flavell/...ers-fonts.html
(search for your own name).
but with ‛ things get _very_ wrong: if I have
<title>test ‛</title>
then IE ignores the entire <title> element and displays the page's URL
in the browser window's top bar where it normally shows the title.


Bizarre.

Jul 20 '05 #4

P: n/a
On Mon, 5 Jan 2004 19:34:16 +0000 (UTC), "Jukka K. Korpela"
<jk******@cs.tut.fi> wrote:
On the other hand, <meta name="description"> is not particularly
important. It is more important to start the _body_ of your document in
an interesting way - in a way that makes human readers immediately
interested and aware of the content and thereby gives good food to
search engines as well.


Generally true, I think, but I did come across one Dutch search engine
recently whose help pages said (or at least implied) that it would only
index pages with a <meta name="description">.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #5

P: n/a
Stephen Poley <sb******************@xs4all.nl> wrote:
I did come across one Dutch search engine
recently whose help pages said (or at least implied) that it would
only index pages with a <meta name="description">.


Luckily there is a rich supply of search engines, so that we can ignore
such search engines that have no chances of getting much importance.
A search engine that decides to restrict searches to a small minority
of pages is hardly a successful effort.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.