Forum Moderators: open

Message Too Old, No Replies

single quotes or double quotes?

within META and HTML tags

         

Reid

4:37 am on May 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I always thought that it must be double quotes
but I have looked at several 'other peoples ' sites lately and continually run into
<a href='ht*p://w*w.example.com'>home</a> and it seems to work
same with
<meta name='keywords' content='blahblah'>

Also on META tags some people use a trailing slash in the META tags
<meta name="base" href="ht*p://w*w.example.com/widgets.htm" />

what is up with the single quotes and the trailing slash?

wruppert

4:48 am on May 17, 2005 (gmt 0)

10+ Year Member



You can use single or double quotes, see [w3.org...]

XHTML requires all <tag>'s to end with a </tag>. If there is no enclosed data than a trailing " />" can be used. Thus <br> becomes <br />, <hr> becomes <hr /> and <image ...> becomes <image ... />, the </p> is mandatory, etc.

Reid

11:38 pm on May 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what about mixing them?
some elements use single some double
any problem with that?

encyclo

12:44 am on May 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what about mixing them?

Technically it's no problem as long as you are using the same quotes for the beginning and ending a value: ie. not "value', just "value" or 'value'. It is best practice to keep a consistent coding style, but that's about it. You should not, however, use trailing slashes (such as

<br [b]/[/b]>
in HTML documents, only in XHTML documents.

Reid

3:33 am on May 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok - what about META tags?

some do and some don't have the trailing slash at the end
<META name='keywords' content='word1,word2' />

rjohara

3:39 am on May 18, 2005 (gmt 0)

10+ Year Member



XHTML requires that all elements be *closed*. Once upon a time in earlier versions of HTML it was permissible to write:

<p>some text
<p>more text

But in XHTML (which is really just "HTML 5") you must write:

<p>some text</p>
<p>more text</p>

That leaves us with a puzzle when considering those elements which have no content, such as <img> and <meta>. You *must* close them (under the XHTML rules). You can write <img></img> or <meta></meta> if you wish, but the short form is to close them with /> like this:

<img />
<meta />

Reid

6:49 am on May 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok thanks - that clarifies things perfectly.