*
The moose likes HTML, CSS and JavaScript and the fly likes   not allowed in element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "&nbsp not allowed in element "ul" in this context" Watch "&nbsp not allowed in element "ul" in this context" New topic
Author

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

Ivan Turner
Ranch Hand

Joined: Feb 27, 2012
Posts: 37
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

Joined: Oct 01, 2001
Posts: 2841
    
  11

Use a CSS line-height rule applied to the li elements.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

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

Joined: Jan 10, 2002
Posts: 60810
    
  65

I'd use margin-bottom.

Using text to achieve spacing is a relic from 1998. Use CSS.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

And with regard to your topic title, the non-breakling spaces aren't in the <li> elements.
Ivan Turner
Ranch Hand

Joined: Feb 27, 2012
Posts: 37
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

Joined: Jan 10, 2002
Posts: 60810
    
  65

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

Joined: Jan 10, 2002
Posts: 60810
    
  65

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

Joined: Feb 27, 2012
Posts: 37
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: &nbsp not allowed in element "ul" in this context
 
Similar Threads
HTML drop downs not working
programming problem
For Servlet request, FireFox is opening file for JSON Data
How to overlap two or more <div>s?
set values in a table from other