Cell Background (Full Version)

All Forums >> [Web Development] >> Cascading Style Sheets



Message


whosyodaddy -> Cell Background (11/6/2005 23:04:19)

When validating my index, I get only one error:

quote:

1. Error Line 89 column 47: there is no attribute "BACKGROUND".

<td rowspan="5" bgcolor="#FFFFFF" background="images/index_15.jpg">

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.



It seems as if I cannot use a background image for this particular cell. How would I go about using CSS for it? I have never worked with CSS before. I tried creating a css.css files with contents of only:

quote:

<style type="text/css">
#header-bgimage {
background-image:
url('images/index_15.jpg');
background-repeat: repeat-y
}
</style>


Then for my cell html code I changed it to:

quote:

<td rowspan="5" bgcolor="#FFFFFF" id="header-bgimage">


It was then validated correctly but the background did not show for the cell. I am guessing because my html code does not know how to access the .css file. How can I tell it where it is? Am I doing this correctly?

Thanks




Kitka -> RE: Cell Background (11/6/2005 23:27:02)

quote:

How can I tell it where it is?


For an external stylesheet you need to place a line like this
<link rel="stylesheet" type="text/css" href="css.css">


somewhere between your <head> </head> tags.

quote:

Am I doing this correctly?


No. The code you quoted is only used if you are going to embed the style on the page itself. That code, if placed somewhere between the <head> </head> tags, should result in the background image appearing (if everything else is correct).

Will the background image be required on more than one page? If not, it doesn't make much sense to have an external stylesheet just for that.

If you do need an external style sheet, the only code that should appear in it is this:

#header-bgimage {
background-image: url('images/index_15.jpg');
background-repeat: repeat-y;
} 


Personally, rather than use an id, I would have used a class. e.g.

.bgimage {background: #fff url('images/index_15.jpg') repeat-y ;}


The html code would then look like this:

<td rowspan="5" class="bgimage">


If I've confused you please ask again. [8|]




whosyodaddy -> RE: Cell Background (11/7/2005 3:08:51)

Yes, it works! Many thanks to you, Kitka[:)]

I'm starting to really like this CSS thing.[;)]




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875