Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-06-2012, 08:23 PM   PM User | #1
CaptainB
Regular Coder

 
Join Date: Jun 2007
Posts: 805
Thanks: 123
Thanked 23 Times in 23 Posts
CaptainB is an unknown quantity at this point
Cross-browser: Non-breaking space

Hey guys,

I have a breadcrumbs list that shows users what page they are browsing relative to the main page. The list is made using an ul and after each link in every list item (except for the last one) I am using the below to inset an arrow + an extra space:

Code:
#breadCrumbs a:after {
    content: ' >\0000a0';       /*  as escaped unicode. To add extra space after arrow. */
                }
Every browser except IE7 renders the escaped unicode as a space. However, IE7 does not recognize the unicode and instead outputs it as the following text:

Code:
  
\0000a0
I can use the below format to write the non-breaking space for IE7, but for all other browsers it renders as text instead:

Code:
&#160
Now, the question is if there is a cross-browser solution to this problem. I tried to make IE7 render the code that it understands with the following in an IE-specific stylesheet, but it ignores it completely (but reads the other styles from the IE-specific stylesheet.) So, what do I do?

Code:
*+html #breadCrumbs a:after {
    content: ' >&#160';       /*  as escaped unicode. To add extra space after arrow. */ 
                }
CaptainB is offline   Reply With Quote
Old 11-06-2012, 09:42 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Why not use white-space: nowrap on the list?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-07-2012, 07:46 AM   PM User | #3
CaptainB
Regular Coder

 
Join Date: Jun 2007
Posts: 805
Thanks: 123
Thanked 23 Times in 23 Posts
CaptainB is an unknown quantity at this point
Dear VIPSpethan,

I'm not sure we're talking about the same. As far as I can read, the white-space:nowrap; collapses whitespace into a single space. What I want to is preserve the extra whitespace after the arrow. I tried to do that with the above formats of the non-breaking space but that turns out to either work in some browsers while displaying the code as text instead of a whitespace in others (and vice versa). So, I'm still looking for an universal solution to preserve the extra space.
CaptainB is offline   Reply With Quote
Old 11-07-2012, 10:40 AM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Well, then use the CSS margin property to adjust space with pixel precision. You shouldn’t use HTML to achieve a certain look (and a non-breaking space is basically that), that’s what CSS is there for. You can add a margin to the generated content (the :after rule), too.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-07-2012, 06:41 PM   PM User | #5
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,448
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by CaptainB View Post
As far as I can read, the white-space:nowrap; collapses whitespace into a single space.
Yes it does - to retain all the spaces you'd use white-space : pre

However white-space : nowrap is the solution to your problem of not having a particular space break. Simply wrap the content either side of the space inside a span and apply the style to that.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 11-09-2012, 12:05 PM   PM User | #6
CaptainB
Regular Coder

 
Join Date: Jun 2007
Posts: 805
Thanks: 123
Thanked 23 Times in 23 Posts
CaptainB is an unknown quantity at this point
Margin did the trick - I did not even consider that posibility!
Thank you both for your answers!
CaptainB is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:33 PM.


Advertisement
Log in to turn off these ads.