472,954 Members | 1,663 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,954 software developers and data experts.

Span/background-image IE6 bug?

I have a span containing two words. Eg.

<span>Avant Garde</span>

Using CSS, I pad the text to the right and assign a background-image. Eg.

span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}

The tag renders as expected...unless the line wraps in the middle of the
two words. Then the background-image doesn't appear in IE6, but it
renders fine in Firefox. Is this a browser bug?

To see an example, browse the following URL with IE6 and expand the "10
Tags" link: <http://arty.me.uk/2006/01/04/announcing-avantist/>
--
Walker
arty.me.uk
Jan 5 '06 #1
16 14582

Walker wrote:
I have a span containing two words. Eg.

<span>Avant Garde</span>
To see an example, browse the following URL with IE6 and expand the "10
Tags" link: <http://arty.me.uk/2006/01/04/announcing-avantist/>


I think you should try and mark it up as a list as seeing it is a list.
Anyways backgound images and inline elements don't always play well.

Jan 5 '06 #2
logic_earth wrote:
Walker wrote:
I have a span containing two words. Eg.

<span>Avant Garde</span>


To see an example, browse the following URL with IE6 and expand the "10
Tags" link: <http://arty.me.uk/2006/01/04/announcing-avantist/>


I think you should try and mark it up as a list as seeing it is a list.
Anyways backgound images and inline elements don't always play well.


Don't play well in IE6 or current browsers in general? The code is
valid, the outcome should be obvious, and Konqueror, Opera and Firefox
all render it as expected. :)

(I was playing around forever with an unordered list solution before
choosing the span option, but I had some difficult that I can't recall.
I'll have a play around with the idea again anyway.)
--
Walker
arty.me.uk
Jan 5 '06 #3
Els
Walker wrote:
span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}

The tag renders as expected...unless the line wraps in the middle of the
two words. Then the background-image doesn't appear in IE6, but it
renders fine in Firefox. Is this a browser bug?


I'm not sure it's a bug, but it is a difference, yes.
The thing is, that when you state 'left' or '0px' for the horizontal
position of the background-image, IE assumes 'left' of the entire
span. When the span is divided over 2 lines, the left side of the
whole span, is on the left of the second line. Out of sight when you
set it 2px from the top.

A workaround might be to have two spans:

<span><span> </span>some words</span>

span span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Magnum - Walking The Straight Line
Jan 5 '06 #4
On Thu, 05 Jan 2006 22:47:38 +0100, Els <el*********@tiscali.nl> wrote:
Walker wrote:
The tag renders as expected...unless the line wraps in the middle of the
two words. Then the background-image doesn't appear in IE6, but it
renders fine in Firefox. Is this a browser bug?


A workaround might be to have two spans:

<span><span> </span>some words</span>

span span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}


Or to prevent the line break (if the span is just a two or three words
anyway).
--
,-- --<--@ -- 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 |
`-------------------------------------------------- --<--@ ------------'
Jan 5 '06 #5
Els wrote:
Walker wrote:

span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}

The tag renders as expected...unless the line wraps in the middle of the
two words. Then the background-image doesn't appear in IE6, but it
renders fine in Firefox. Is this a browser bug?

I'm not sure it's a bug, but it is a difference, yes.
The thing is, that when you state 'left' or '0px' for the horizontal
position of the background-image, IE assumes 'left' of the entire
span. When the span is divided over 2 lines, the left side of the
whole span, is on the left of the second line. Out of sight when you
set it 2px from the top.

A workaround might be to have two spans:

<span><span> </span>some words</span>

span span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}


Thank-you! I've tested the code offline and it fixes the problem and
renders identically in Opera and Firefox. :) I just had to alter the
padding of outer and inner spans because, being only applied to the
inner span, it was pushing the text (now in the outer span) to the right.

I've spent so many hours fighting browser inconsistencies (taming lists,
getting to grips with the box model, etc.) without relying on hacks that
it seems amazing that something like this had me stumped. And I'd never
have thought of this solution. Look me up if you're ever in Manchester
and I'll buy you a pint. ;-)
--
Walker
arty.me.uk
Jan 5 '06 #6
Walker wrote:
Els wrote: // Thank-you! I've tested the code offline and it fixes the problem and
renders identically in Opera and Firefox. :) I just had to alter the
padding of outer and inner spans because....


I knew there was something I forgot to mention. IE6 ignored the inner
span because it saw nothing but whitespace. So I just inserted an
&nbsp; and that fixed it. Eg.

<span><span>&nbsp;</span>some words</span>

--
Walker
arty.me.uk
Jan 5 '06 #7
Els
Barbara de Zoete wrote:
On Thu, 05 Jan 2006 22:47:38 +0100, Els <el*********@tiscali.nl> wrote:
Walker wrote:
The tag renders as expected...unless the line wraps in the middle of the
two words. Then the background-image doesn't appear in IE6, but it
renders fine in Firefox. Is this a browser bug?


A workaround might be to have two spans:

<span><span> </span>some words</span>

span span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}


Or to prevent the line break (if the span is just a two or three words
anyway).


Yup - that would work very well too <g>
(I hadn't seen the actual situation and had a much longer span in my
imaginary example problem ;-) )

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: INXS - Bitter Tears
Jan 6 '06 #8
Walker wrote:

I was playing around forever with an unordered list solution before
choosing the span option, but I had some difficult that I can't recall.

See <http://css.maxdesign.com.au/listamatic/>

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jan 6 '06 #9
Jim Moe wrote:
Walker wrote:
I was playing around forever with an unordered list solution before
choosing the span option, but I had some difficult that I can't recall.


See <http://css.maxdesign.com.au/listamatic/>


Been there, done that. Inline lists with background-images and padding
are afflicted by more problems in IE6 than the span method I chose.
Exactly the same rendering problem was occurring on the final list item
on a line for example, and getting the padding and margins consistent
across all browsers was more trouble than it was worth.

IE6 just always wanted to do something differently. With this span
solution, I've got the faux list rendering how I would like across the
big three browsers...oh, and Konqueror too.
--
Walker
arty.me.uk
Jan 6 '06 #10
Els wrote:
Barbara de Zoete wrote:
On Thu, 05 Jan 2006 22:47:38 +0100, Els <el*********@tiscali.nl> wrote:
Walker wrote:
The tag renders as expected...unless the line wraps in the middle of the
two words. Then the background-image doesn't appear in IE6, but it
renders fine in Firefox. Is this a browser bug?

A workaround might be to have two spans:

<span><span> </span>some words</span>

span span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}


Or to prevent the line break (if the span is just a two or three words
anyway).


Yup - that would work very well too <g>


Presumably with { white-space: nobr } ? I tried that a few days ago but
it invalidated the code.

--
Walker
arty.me.uk
Jan 6 '06 #11
Els
Walker wrote:
Els wrote:
Barbara de Zoete wrote:
On Thu, 05 Jan 2006 22:47:38 +0100, Els <el*********@tiscali.nl> wrote:

Walker wrote:
>The tag renders as expected...unless the line wraps in the middle of the
>two words. Then the background-image doesn't appear in IE6, but it
>renders fine in Firefox. Is this a browser bug?

A workaround might be to have two spans:

<span><span> </span>some words</span>

span span {
padding: 0 3px 0 11px;
background: url(images/tagbull.gif) no-repeat 0px 2px;
}

Or to prevent the line break (if the span is just a two or three words
anyway).


Yup - that would work very well too <g>


Presumably with { white-space: nobr } ? I tried that a few days ago but
it invalidated the code.


No, with &nbsp;

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jan 6 '06 #12
Els wrote:
Walker wrote:
Els wrote:
Barbara de Zoete wrote:

Or to prevent the line break (if the span is just a two or three words
anyway).

Yup - that would work very well too <g>


Presumably with { white-space: nobr } ? I tried that a few days ago but
it invalidated the code.


No, with &nbsp;


Ah, I didn't know an &nbsp; would do that. I'll make a mental note of
it. Probably not the best solution for this scenario because the tags
(and spaces between words) are generated by a third-party PHP plugin
which I'd rather not modify -- otherwise, everytime there's a new
release, I'd have to do the mod all over again. The beauty of your
nested span solution is that the PHP function accepts the before and
after tags as a parameter, so I only have to modify my own template.

--
Walker
arty.me.uk
Jan 6 '06 #13
Els
Walker wrote:
Els wrote:
Walker wrote:
Els wrote:

Barbara de Zoete wrote:

>Or to prevent the line break (if the span is just a two or three words
>anyway).

Yup - that would work very well too <g>

Presumably with { white-space: nobr } ? I tried that a few days ago but
it invalidated the code.
No, with &nbsp;


Ah, I didn't know an &nbsp; would do that.


&nbsp; -> non breaking space :-)
I'll make a mental note of
it. Probably not the best solution for this scenario because the tags
(and spaces between words) are generated by a third-party PHP plugin
which I'd rather not modify -- otherwise, everytime there's a new
release, I'd have to do the mod all over again. The beauty of your
nested span solution is that the PHP function accepts the before and
after tags as a parameter, so I only have to modify my own template.


Good :-)

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jan 6 '06 #14
Walker <wa**********@gmail.com> wrote:
The tag renders as expected...unless the line wraps in the middle of the
two words. Then the background-image doesn't appear in IE6, but it
renders fine in Firefox. Is this a browser bug?


No, not really.

This is a detail that is explicitly not yet addressed by the CSS 2.1
standard. Here's what the official CSS 2.1 specification says:

"The tiling and positioning of the background-inamge on inline
elements is ndefined in this spcification. A future level of CSS may
define the tiling and positioning of the background-image on inline
elements."

<http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat>

--
Alexander
Jan 6 '06 #15
Els wrote:

Presumably with { white-space: nobr } ? I tried that a few days ago but
it invalidated the code.

Because it should have been: { white-space: nowrap; }

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jan 6 '06 #16
Els
Jim Moe wrote:
Els wrote:

Presumably with { white-space: nobr } ? I tried that a few days ago but
it invalidated the code.

Because it should have been: { white-space: nowrap; }


Wasn't me that typed the post you are replying to - please don't
misquote :-)

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jan 6 '06 #17

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

Similar topics

3
by: kAldam | last post by:
I am currently using IE 6.0 and 5.5 and the scenario is the following. I have a span that contains text, and the span is beign contained by a table cell (this is the way thing need to be in my...
2
by: Mr. Clean | last post by:
Why would this work: <html> <head> <title>Page 1</title> </head> <body style="background:#C2BFA5;"> <span style="text-align: center; border:thin inset; position:absolute; left:14px;
0
by: JimO | last post by:
I'm new to CSS and I'm trying to figure out the difference between the Header tags, div, span, and p tags as they relate to style sheets. They each render slightly different in the browser and...
2
by: JimO | last post by:
I'm new to CSS and I'm trying to figure out the difference between the Header tags, div, span, and p tags as they relate to style sheets. They each render slightly different in the browser and...
4
by: jawolter | last post by:
I have text that is too long to nicely fit on a given page, so I want to add ellipses to the end that dynamicaly resize based on the person resizing the page width. If you hover it would show the...
2
by: ricky | last post by:
Hello, If anyone could help me with this I would highly appreciate it. I've tried everything and nothing works. What I am trying to do is so damn basic and it's just frustrating that it seems...
2
by: reproots | last post by:
hi there, i am having trouble with a span command and would like to know if someone can help me, or point me in the correct direction. basically, i want a little textbox to pop up when a mouse...
5
by: David Housman | last post by:
Hello, I'm trying to implement a navigation bar with a ul in css. The code is a template, but i'm customizing. I can handle just text in each block, but i want the first block to have an image...
2
by: pbd22 | last post by:
Hi. I have been wrestling with getting a span (or a few) to live inside a few divs. I want to put padding around the span but it seems to move independent of the divs even though there is no...
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=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.