473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 14604

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.