Forum Moderators: open

Message Too Old, No Replies

Double Quoting Attribute Values

Why do I do it?

         

chris_f

3:36 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi All,

I have always double quoted my values when I code a page. For example:

<img src="image.gif" alt="Image" border="0" width="100" height="30">

After viewing some sites that don't use quotes (unless for instance, there is a space in the alt tag) I have wondered about removing the quotes from my sites (mainly for bandwidth saving). I have alway been taught to quote, either single or double. I double quote because of my ASP background as it is easier to tell the difference between ASP and HTML code. Why should you quote?

Chris.

andreasfriedrich

3:46 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In HTML it is not required but good practice:
[w3.org...]

In XHTML it is required:
[w3.org...]

Andreas

Macguru

3:46 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Placing quotation marks around attributes is required for compatibility with certain early browsers and for strict HTML compliance. Always quoting attributes is recommended when necessary to comply with most browsers.

Not really necessary unless you need strict HTML complience.

<added>You beat me andreasfriedrich!</added>

lorax

3:50 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's also a good habit to get into as most scripting languages require it to denote strings and values of variables.

chris_f

4:17 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gggrrrr.

Not something I can drop them ;).

Thanks guys.
Chris.

txbakers

4:22 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is required in 4.01 HTML for attributes that have non-numeric or alpha characters such as "%".

g1smd

9:50 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In HTML 4.01 any attribute with a space, % : / # or any character other than A to Z and 0 to 9 must be Quoted. However the spec recommends to quote all attributes.

However, as a very minimum, all "50%" sizes, all URLs, all "#FFFFFF" colours, and attributes like type="text/javascript" and type="text/css" should be quoted.