• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

&nbsp not allowed in element "ul" in this context

 
Ivan Turner
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, The code below doesn't cause a problem and it does exactly what I want it to do which is put 2 spaces between the links. The www.w3.org validator doesn't like it. How can this be done without the nbsp?

I had to leave the & off so they would show on the page!!!

Thanks,
Cerito
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a CSS line-height rule applied to the li elements.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Turner wrote:
I had to leave the & off so they would show on the page!!!

If you are going to be using HTML entities, it's a good idea to understand them. I can make it appear: &   and so on.

As an exercise, figure out how I did that.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd use margin-bottom.

Using text to achieve spacing is a relic from 1998. Use CSS.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And with regard to your topic title, the non-breakling spaces aren't in the <li> elements.
 
Ivan Turner
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without the nbsb, the output is xxxyyyzzz, I'm using nbsp for spacing but I want xxx yyy zzz output without using it. The nbsp works fine. Though I'm satisfied with the nbsp, is there a simple way to put spaces between the list elements that won't upset the validator?

Thanks for the suggestion. When I have time, I'll figure out how to make the & appear. Disable HTML doesn't do it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you already have CSS to make the list elements appear on the same line? By default, they will appear vertically stacked.

So think! If margin-bottom would add vertical spacing, what could be used to add horizontal spacing?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Turner wrote:I'll figure out how to make the & appear. Disable HTML doesn't do it.

No forum tricks; simple markup that would work on any HTML page.
 
Ivan Turner
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:So you already have CSS to make the list elements appear on the same line? By default, they will appear vertically stacked.

So think! If margin-bottom would add vertical spacing, what could be used to add horizontal spacing?


My css entry makes them inline. I guess I need to investigate spacing.
#links li {display:inline; font-size:20px;}
If I change to DOCTYPE xhtml1-transitional.dtd, the error &nbsp validation problem goes away.

How ya like me now Bear Bibeault?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not have whitespaces dangling inside of that tag. If you want space characters, they need to live inside of the li element to be valid.

But in reality you need to use padding/margins to pull it off. Basic exaples of using lists as menus http://css.maxdesign.com.au/listamatic/

Eric

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic