472,784 Members | 1,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

<td> with background image - what's the right way?

I have a horizontal navigation bar, which is a single row table containing
the right images. It "stretches" itself across the screen using a
penultimate td like this:

<td width="100%" background="images/nav_bar/nb_spacer.gif">&nbsp;</td>

which works in all major browsers that I've tried, but doesn't validate. No
background attribute to the td tag, apparently.

What is the correct way to do this? A stylesheet entry with a
background-image? I've tried what look like sensible permutations, based
around this:

<td width="100%" style="background-image:
images/nav_bar/nb_spacer.gif">&nbsp;</td>

but none of them show the image. Changing that line to set the background
colour to blue works, so I must be doing something fundamentally wrong.

--
The email address used to post is a spam pit. Contact me at
http://www.derekfountain.org : <a
href="http://www.derekfountain.org/">Derek Fountain</a>
Jul 23 '05 #1
5 116696
Derek Fountain wrote:
I have a horizontal navigation bar, which is a single row table containing
the right images.
Single row? That doesn't sound like tabular data. Try a list instead.
http://css.maxdesign.com.au/listamatic/
What is the correct way to do this? A stylesheet entry with a
background-image?
Yes
<td width="100%" style="background-image:
images/nav_bar/nb_spacer.gif">&nbsp;</td>


CSS is a nice manual which can tell you what the syntax is ...
http://www.w3.org/TR/CSS2/colors.htm...ckground-image
.... and a validator so you can test you code ...
http://jigsaw.w3.org/css-validator/

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2
On Fri, 04 Mar 2005 16:51:07 +0800, Derek Fountain <no****@example.com> wrote:
I have a horizontal navigation bar, which is a single row table containing
the right images.
A navigation menu usually is just a list of links that take a visitor anywhere
within the site they're at. What makes your navigation menu tabular data?
It "stretches" itself across the screen using a
penultimate td like this:

<td width="100%" background="images/nav_bar/nb_spacer.gif">&nbsp;</td>
Ugly hack.
which works in all major browsers that I've tried, but doesn't validate. No
background attribute to the td tag, apparently.
That might be, because usually tabular data can do just fine without a
background image :-)
From <http://www.w3.org/TR/html401/struct/tables.html#edef-TD>:

<blockquote>
<!ELEMENT (TH|TD) - O (%flow;)* -- table header cell, table data cell-->
<!-- TH is for headers, TD for data, but for cells acting as both use TD -->
<!ATTLIST (TH|TD) -- header or data cell --
%attrs; -- %coreattrs, %i18n, %events --
abbr %Text; #IMPLIED -- abbreviation for header cell --
axis CDATA #IMPLIED -- comma-separated list of related
headers--
headers IDREFS #IMPLIED -- list of id's for header cells --
scope %Scope; #IMPLIED -- scope covered by header cells --
rowspan NUMBER 1 -- number of rows spanned by cell --
colspan NUMBER 1 -- number of cols spanned by cell --
%cellhalign; -- horizontal alignment in cells --
%cellvalign; -- vertical alignment in cells -- </blockquote>

Nope, it's not there.
What is the correct way to do this?


You can check my site for a horizontally layed out navigation menu, using lists.
It is not hard to add the image rollover effect as a background property with
CSS. Google for CSS Rollovers. You can find a something to get you started at:
<http://www.alistapart.com/articles/taminglists/> and
<http://www.alistapart.com/articles/dropdowns/>

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
Jul 23 '05 #3
David Dorward <do*****@yahoo.com> wrote:
What is the correct way to do this? A stylesheet entry with a
background-image?


Yes


Not quite. Normally it is best to use the shorthand property, e.g.
background: url(images/nav_bar/nb_spacer.gif);
Not really for shortness but for the reason that this also sets the
background-color property (to the initial value, transparent - you can also
specify an explicit value of course).

This is one of the many reasons why it is better to set background images (if
you use them) in CSS: it's much easier to set all the relevant properties
(background image, background color, text color, and the four link colors)
consistently and without fear of some nasty alien style interfering
unpredictably.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #4
> Single row? That doesn't sound like tabular data. Try a list instead.
http://css.maxdesign.com.au/listamatic/
I clicked on a dozen or so of those horizontal list examples and none of
them seemed to do what I want. Maybe one does, but I couldn't see it. See
my website linked in the footer of this post: my navigation bar is a set of
images containing image maps, not just flat words. The graphics were
produced with Adobe Imageready.
CSS is a nice manual which can tell you what the syntax is ...
http://www.w3.org/TR/CSS2/colors.htm...ckground-image


Ah, missed the url() thingy. Thanks for the pointer.

--
The email address used to post is a spam pit. Contact me at
http://www.derekfountain.org : <a
href="http://www.derekfountain.org/">Derek Fountain</a>
Jul 23 '05 #5
me
"Derek Fountain" <no****@example.com> wrote in message
news:42**********************@per-qv1-newsreader-01.iinet.net.au...
I have a horizontal navigation bar, which is a single row table containing
the right images. It "stretches" itself across the screen using a
penultimate td like this:

<td width="100%" background="images/nav_bar/nb_spacer.gif">&nbsp;</td>

which works in all major browsers that I've tried, but doesn't validate. No background attribute to the td tag, apparently.

What is the correct way to do this? A stylesheet entry with a
background-image? I've tried what look like sensible permutations, based
around this:

<td width="100%" style="background-image:
images/nav_bar/nb_spacer.gif">&nbsp;</td>

but none of them show the image. Changing that line to set the background
colour to blue works, so I must be doing something fundamentally wrong.

--
The email address used to post is a spam pit. Contact me at
http://www.derekfountain.org : <a
href="http://www.derekfountain.org/">Derek Fountain</a>


IIRC the following will validate.
Good Luck,
me

The syntax below is for a style sheet in the head of the document:

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
..bgimage { background-image: url(arrow.gif); background-repeat: repeat}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="bgimage">
<p>text</p>
</td>
</tr>
</table>
</body>
</html>

The syntax below is for an external style sheet:

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="bgimage.css">
</head>
<body bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="bgimage">
<p>text</p>
</td>
</tr>
</table>
</body>
</html>

Below is the contents of the external style sheet named bgimage.css:

..bgimage { background-image: url(arrow.gif); background-repeat: repeat}
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim | last post by:
Hey all, I am trying to generate a random image output that will appear like this - http://wd-santabarbara.com/atex/ . I am not sure of where to start on this or even if I am using the right...
5
by: MyndPhlyp | last post by:
I've been busting my head trying to figure this out for quite some time. With IE6 and NS7, no problems. I can simply code the HTML <img height="100%"> and be done with it. But NS4 and NS6 (and...
2
by: Andre | last post by:
My website at http://www.oregonsae.org/2004mbw/ is a simple three column table. There is only one table, and one row. The menu on the left side is one <TD>, the content in the center is another...
14
by: Zenobia | last post by:
Hello folks, Is it possible to position an item within a <td> element? For instance see below. The table has multiple rows, one for each database record. Each row has 3 hrefs associated with it...
4
by: Dominic | last post by:
I'm looking for a HTML editor that can match the opening and closing HTML tags such as <TR> </TR>, <TD> </TD> I think Dreamweaver does that, right? Even if it does, it may be too expensive for...
4
by: Jason | last post by:
Is that possible? How? <td > <asp:Label ID="StartDateLabel" runat="server" Text="Start Date:"> <asp:imagebutton ID="Imagebutton1" width=18 Height=18 CommandName=SetDate imageUrl="../cal.jpg"...
4
by: Nathan Sokalski | last post by:
I have a <tdthat contains several elements, some of which are left-aligned, right-aligned, or centered. I do not know the widths of these elements beforehand, so I cannot give my <tda fixed width....
1
by: alex.pedwysocki | last post by:
Having trouble googling this one. I have a dynamically generated table that I'd prefer not to set sizes for. Is there any way to know the size that the browser is using to display this cell?...
9
by: Lloyd Sheen | last post by:
I have now spent the entire morning on what I think should be easy. I cannot for the life of me figure out how to make a simple one row, two column table where is the contents of the one of the...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.