html validate problem

Associate
Joined
17 Oct 2002
Posts
312
Location
herts
hi there
the code below fails validation on w3c validator.
the bit it fails on is the background image property on the 2nd td tag on the top table.
the table below it is identical but validates fine.
anybody see a mistake that i havent spotted? or know what the problem is?

Code:
      <table width=500 align=center border=0 cellpadding=1 cellspacing=1 bgcolor=blue>
       <tr>
      	<td align=center valign=middle width=125 bgcolor=yellow>Season</td>
    	  <td align=center valign=middle bgcolor=white background="images/background/lightblue.gif">Months</td>
    	  <td align=center valign=middle width=125 bgcolor=yellow>Weekly</td>
    	 </tr>

    	</table>
<br>
      <table width=500 align=center border=0 cellpadding=1 cellspacing=1 bgcolor=blue>
       <tr>
      	<td align=center valign=middle width=125 bgcolor=yellow>Low Season</td>
    	  <td align=center valign=middle bgcolor=white background="images/background/lightblue.gif">1st January<br>-29th February</td>
    	  <td align=center valign=middle width=125 bgcolor=yellow>400<br></td>

    	 </tr>

cheers

matt

forgot to say this is in the doc

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">

and

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 
Last edited:
thanks aharvey

they say that but it works :p
i just cant understand why the table below it is exactly the same but it does not throw an error there :confused:

cheers

matt
 
You should give the table/tds etc classes in css and control all styling from there, this is a much better way of doing things as then if you decide you want to quickly change styling you can modify the appropriate class rather than trawling through your html modifying all instances of a td or something.

Also you should close your break tags or not use them at all if possible "<br />" is the correct html for the element, and get your code aligned correctly so you can quickly spot unclosed tags etc.

CSS example.
Code:
td.withBackground
{
background-color:#000000;
background-image:url(url_to_image);
} 

then set <td class="withBackground">TEXT</td>
 
Last edited:
thanks aharvey

they say that but it works :p
i just cant understand why the table below it is exactly the same but it does not throw an error there :confused:

cheers

matt

Actually, I tried the bottom table on its own and it throws the exact same errors:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">


<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<table width=500 align=center border=0 cellpadding=1 cellspacing=1 bgcolor=blue>
       <tr>
      	<td align=center valign=middle width=125 bgcolor=yellow>Low Season</td>
    	  <td align=center valign=middle bgcolor=white background="images/background/lightblue.gif">1st January<br>-29th February</td>
    	  <td align=center valign=middle width=125 bgcolor=yellow>400<br></td>

comes up with the following 2 errors:

Line 11, Column 63: there is no attribute "BACKGROUND".

…lign=middle bgcolor=white background="images/background/lightblue.gif">1st Ja

and

Error Line 12, Column 75: end tag for "TABLE" omitted, but its declaration does not permit this.

…ddle width=125 bgcolor=yellow>400<br></td>



* You forgot to close a tag, or
* you used something inside this tag that was not allowed, and the validator is complaining that the tag should be closed before such content can be allowed.
 
ok thanks for the help people.

strange that as it lists other errors that i fixed all together, but for some reason it stops here until i fix that one before it will catch the next one.:confused:

anyway its temporary until i got time for a redesign i just wanted to make google happy until i do it with css/xhtml.

i have a feeling it maybe to do with my doctype declaration which is html 4.01 transitional.

thanks again

matt
 
hey ladforce

i was using <tag /> for everything that dosent have a seperate closing tag <b></b> but this generated errors due to the doctype i think.

as it is my site validates perfectly apart from the table images.

cheers

matt
 
Background is not supported in HTML4 on TDs.

Do:
<td style="background-image:url(images/background/lightblue.gif);" > </td>.

instead. In fact those BRs are not a problem as you say, I think both errors are due to the background attribute :)
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<table width="500" align="center" border="0" cellpadding="1" cellspacing="1" bgcolor="blue">
       <tr>
      	<td align="center" valign="middle" width="125" bgcolor="yellow">Low Season</td>
    	  <td align="center" valign="middle" bgcolor="white"  style="background: url(images/background/lightblue.gif)">1st January<br />-29th February</td>
    	  <td align="center" valign="middle" width="125" bgcolor="yellow">400<br /></td>
		</tr>
	</table>
</body>
</html>

was missing valid head section, body tags, html closing tag, lots of "speech marks" and the <br> need to be <br /> also restyled the background to a valid inline css background

Fixed it for you 100% valid now (edit for some reason the indentation has gone)
 
Last edited:
Back
Top Bottom