I was just at validator.w3.org testing my site, and it found <td background='bricks.jpg'> as an invalid tag. It said Line 25, Column 29: there is no attribute "background".

I am using XHTML 1.0 Transitional.

Did they really do away with image backgrounds? I can't imagine that they'd want pages to be black and white.

Am I missing something here?

I'm making a webpage for a person, and I want it to be compliant with all browsers, so I was striving to make it XHTML compliant.

He wants a brick pattern as the background for his left ajax menu, but the validator won't let me. What's going on?

Any help is greatly appreciated.

Hi,
I have viewed My Websites in 4 different browsers and I have never seen a problem going against that code error. I will check yours for you if you would like :) I wanted to add that I think they are trying to get people to use css for the backgrounds in tables instead of relying on the HTML code.

In XHTML, the background and bgcolor attributes have been deprecated. This is because they can easily be implemented with css. If you want it to validate, use

<td style="background-image:url(bricks.jpg)">

However, the best way to do this would be to put these sort of styles in an external stylesheet. This way, it can be cached by the browser and not retrieved repeatedly for each concurrent page that uses the style. This will not only clean up your html, but will also cut down on page load time resulting in a better experience for the user.

Thanks for your replies. BuddyLee: I tried that in an external style sheet but it doesn't load the image on the page. Know why? Here is my tag for it:

TD.MAINCELL{
	FONT-WEIGHT: bold; FONT-SIZE: 105%; background-image: url("bricks.jpg"); BACKGROUND: white; COLOR: blue; FONT-FAMILY: "arial", sans-serif
}

Thanks

Put the background attribute before the background image. This has to do with the order the browser applies the attribute styles in. I would also try to get away from using all caps for the attributes.

TD.MAINCELL{
	font-weight: bold; 
	font-size: 105%; 
	background: white;
	background-image: url("bricks.jpg"); 
	color: blue;
	font-family: "arial", sans-serif
}

Thanks for your help guys, the CSS worked.

Thanks for your replies. BuddyLee: I tried that in an external style sheet but it doesn't load the image on the page. Know why? Here is my tag for it:

TD.MAINCELL{
	FONT-WEIGHT: bold; FONT-SIZE: 105%; background-image: url("bricks.jpg"); BACKGROUND: white; COLOR: blue; FONT-FAMILY: "arial", sans-serif
}

Thanks

Capital letters are not allowed in styles, attributes, and tags in xhtml.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.