Forum Moderators: coopster

Message Too Old, No Replies

attribute value: $color = "#E9E9E9";

why quote marks around attribute values are not parsed?

         

tito

3:27 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



Hello,

i'm using a script to alternate row colors while displaying MySql results on my pages. when i'm trying to validate my page at W3C i get an error related to:

$color = "#E9E9E9";

W3C validation says: "an attribute value must be a literal unless it contains only name characters"

it means that quote marks are not parsed on the html output, the W3C validator reads as:

</tr><tr bgcolor=#E9E9E9>
(notice there's no quote marks)

how can i make my code to display the quote marks around attribute values on the parse?

thanks in advance,
tito

coopster

3:57 pm on Jul 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Put single quotation marks around it:
$color = '"#E9E9E9"';

tito

4:21 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



Thanks a lot Coopster!

lobo235

4:51 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



You could also do the following:


$color = "\"#E9E9E9\"";

The \" escapes the quote so it does not get parsed making it part of the string.

whoisgregg

5:47 pm on Jul 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could also echo the value inside the quotes, like this:

</tr><tr bgcolor="<?php echo $color;?>">