tags:

views:

202

answers:

5

I have the code like this

<div>
<span>This is text</span>
<span>
    <dl>
        <dt><a href="#"><span>Please select category</span></a></dt>
        <dd>
            <ul>
                <li><a href="#">Brazil<span class="value">Cat1</span></a></li>
                <li><a href="#">France<span class="value">Cat2</span></a></li>
            </ul>
        </dd>
    </dl>
</span>
</div>

The output I want is in one line like this.

This is text {Please Select Category dropdownbox}

Currently, the problem i got is, it became two line.

How can i get it into one line ? Please kindly help me with it. Thanks.

A: 

Something like this should do it.. in your CSS stylesheet, add:

dt {width: 100px; text-align:right; float:left; clear:left; line-height: 22px; padding-right: 3px;}
dd {margin-left: 100px; line-height: 22px;}

Hope this helps!

Mark B
it doesn't work. output is like thishttp://img16.imageshack.us/img16/5746/outputspanfloat1.jpgcan you help me to solve again ? Thanks.
Apologies, I misunderstood the question. There are some other answers here now which will work - please check them.
Mark B
A: 

In the CSS:

dl, dd, dt { display: inline; }

But you probably won't like the result. Why do you use a definition list anyway? Just use spans and the UL.

Aaron Digulla
yea, actually, i want to use this dropdown box, that's why http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspxit's using definition list.
A: 

Change the second line of your code:

<span style="float: left">This is text</span>

Edit:

Change your code to:

<div style="float: left;">This is text</div>
<div style="margin-left: 80px;">
    <dl>
        <dt><a href="#"><span>Please select category</span></a></dt>
        <dd>
            <ul>
                <li><a href="#">Brazil<span class="value">Cat1</span></a></li>
                <li><a href="#">France<span class="value">Cat2</span></a></li>
            </ul>
        </dd>
    </dl>
</div>
Anax
this worked. but output is like thishttp://img269.imageshack.us/img269/8526/outputspanfloat.jpgI want to have space between This is text and Select Category, how can i do ? Thanks much for helping.
<span style="float: left">This is text </span>
Anax
it's only move the Select Category text, not the entire definition list.
A: 

There is always the possibility to use a table.

<div>
<table><tr><td  valign=top >
<span><dl>This is text</span>
</td><td width=15 >&nbsp;</td><td   valign=top  >
<span>
    <dl>
        <dt><a href="#"><span>Please select category</span></a></dt>
        <dd>
            <ul>
                <li><a href="#">Brazil<span class="value">Cat1</span></a></li>
                <li><a href="#">France<span class="value">Cat2</span></a></li>
            </ul>
        </dd>
    </dl>
</span>
</td></tr></table>
</div>

Hey, I know it's not best looking solution, but it does the job.

Avi Y
great, i totally forgot that fact! Thanks. I got it working now !
http://www.hotdesign.com/seybold/
David Dorward
A: 

Why not use a label element:

<div>
    <label>This is text</label>
    <dl>
     <dt><a href="#"><span>Please select category</span></a></dt>
     <dd>
      <ul>
       <li><a href="#">Brazil<span class="value">Cat1</span></a></li>
       <li><a href="#">France<span class="value">Cat2</span></a></li>
      </ul>
     </dd>
    </dl>
</div>

along with

label,dl
{
    display:inline-block;
}
Eric
Because the label element describes the purpose of a form control, and there is no form control here. (Of course, there isn't a list of definitions either…)
David Dorward
Actually, Isaveit says that he/she is using a form control, albeit a jquery created one. This is the one he/she was talking about: http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx
Eric
/me pokes at the demo. What a disgustingly inaccessible mess.
David Dorward