tags:

views:

115

answers:

5

Hai, I need to display like this in HTML It should be in 2 column format

.Apple .Mango
.Orange .Banana
.Grapes

Can any one post some sample code or url Thanks in Advance

+2  A: 

Take a look here...

http://www.w3.org/TR/html401/struct/lists.html

Yves M.
A: 

Hai, to make a list you do:

<list>
<item>Apple</item>
<item>Mango</item>
<item>Orange</item>
<item>Banana</item>
<item>Grapes</item>
</list>
wordupyow
@wordupyow <list>?
Chris
Is this a joke?
Skilldrick
@wordupyow : This lists all the items in one line.
Sanjeev
This isn't valid html.
FUZxxl
@Sanjeev use some CSS to put the list on new lines
wordupyow
@wordupyow By Default list items come in next lines, but I need to display it in the manner which I showed in the question. Can you plz help
Sanjeev
You should rarely use arbitrary XML, and almost never when you are writing HTML. HTML has perfectly good list markup of its own, use that instead.
David Dorward
Wtf, some dumbass answer got accepted!
wordupyow
Hu? w3c added a new html tag and I didn't hear 'bout it? Must be my age...
Yves M.
@Yves M. Yeah, you really need to brush up on your skills.
wordupyow
@wordupyow Yes, it was a bad answer that was accepted (and while it has been improved, it still isn't very good). That said, it was still better then your answer (since it kinda works).
David Dorward
A: 

You can try something like

<div style="float:left">
<ul>
  <li>List</li>
  <li>one</li>
</ul>
</div>
<div style="float:left">
<ul>
  <li>List</li>
  <li>two</li>
</ul>
</div>

Please note, that it's highly discouraged to use tables to format your webpage. (That's the reason why I removad that section) It's really better to use <div> and <span>

FUZxxl
@FUZxxl: I tried this just now and about to post the code which I wrote. Nyway this was the code I was looking. Thanks FUZxxl.
Sanjeev
Who voted me down? Please explain.
FUZxxl
@FUZxxl: I haven't used div tag because I don't know how to use that. This code was really helpful for me and itz too simple to understand. Thanks again FUZxxl
Sanjeev
@Sanjeev You REALLY need to learn HTML if you're going to be making web pages. It's unacceptable to not know what a div tag is.
Skilldrick
Vote me up, if you can!
FUZxxl
I think you were downvoted for your HTML which belongs in the 90s.
Skilldrick
@Skilldrick : I know div tag. But I always use table instead of div. Now I am trying to make webpages with div tags only. I voted u up and thanks again. :)
Sanjeev
@Skilldrick: I know, that such ind of html is completely outdated, but from a question of this kind you can easily guess, that the user who asked the question may be a freshman to html. So I explained the "oldschool-outdated" an the "recommend" way.
FUZxxl
why teaching a "newbie" outdated ways
Nealv
Abusing tables for layout was a bad idea but done anyway because CSS wasn't around. Now CSS is around people can do it the right way so there is no need to teach people how to do it the wrong way.
David Dorward
I removed that table stuff. I am really afraid of answering questions if I get down voted because I didn't answered it the "recommend" way.
FUZxxl
A list should be a list, not multiple lists.
David Dorward
@FUZxxi It's not a matter of 'recommended' or not - there *is* one best method to achieve this, when you look at each solution in terms of cleanliness, browser support and conformity to specifications. Using `table` for this is blatant disregard for the specs, and recommending it to anyone as a solution **will** get you downvoted.
Yi Jiang
@FUZxxl: Getting downvotes can feel discouraging, but not answering the "recommended"/right way is pretty much why downvotes exist. Don't take it personally. The primary purpose of SO is to collect good answers, not points.
Michael Petrotta
@Michael Petrotta: Yes. Next time, I'm going to answer correctly.
FUZxxl
A: 

Add to your stylesheet:

li { 
    width: 50%;
    margin: 0;
    padding: 0;
    border: 0;
    float: left;
}

You'll probably want to tweak it, but that makes a reasonable starting point.

David Dorward
+2  A: 

There are two ways to do this correctly. The HTML will stay the same in either case:

<ul class="two-col">
  <li>Apple</li>
  <li>Mango</li>
  <li>Orange</li>
  <li>Banana</li>
</ul>

Now for the CSS. First of all, you can use floats:

.two-col {
  overflow: hidden;
}

.two-col li {
  width: 130px; /* Change this to any amount you want */
  margin-right: 10px;
  float: left;
}

Or you can use the new CSS3 column property (note it is not supported on IE8 and below):

.two-col {
  column-count: 2;
  -moz-column-count: 2;
  -webkit-column-count: 2;
}

This will automatically give each column half of their original width. Fiddle around with it here: http://www.jsfiddle.net/4jLK7/

Yi Jiang