king
king

Reputation: 1344

How do I position text wrapped in divs next to each other?

I want this text all on one line, not spaced on two sepearate lines. How can it be done?

<div id="titlefont">
    <div id="boldness">This text</div>should be next to each other
</div>​
#titlefont {
       font-family:arial;
       font-size:30px;
       text-align:center;
       color:#35404c;
}

 #boldness {
       font-weight:bold;
       font-style:italic; 
}

http://jsfiddle.net/nfSku/

Upvotes: 1

Views: 113

Answers (2)

iambriansreed
iambriansreed

Reputation: 22241

By default divs are rendered as block elements which clear any other elements when not floated.

Fiddle: http://jsfiddle.net/iambriansreed/eu7AW/

CSS:

#boldness {
    font-weight:bold;
    font-style:italic; 
    display: inline;
} 

Upvotes: 3

xan
xan

Reputation: 4696

You can always float the divs or add the display property when trying to show objects in the same horizontal line. Read here if you want to align images and text on the same line.

Upvotes: 1

Related Questions