/    Sign up×
Community /Pin to ProfileBookmark

How tro heep elements on the same line

[B]<div>[/B]
<div id=”1st”>First</div><div id=”2nd”>Second</div>
[B]</div>[/B]

When displayed, the words “First” and “Second” are in two separate lines.

How can I keep them in the same line?

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@bionoidAug 17.2012 — There are a few ways you could do it.

Floating the elements:
[CODE]<div>
<div id="1st" [COLOR="red"]style="float: left;"[/COLOR]>First</div><div id="2nd" [COLOR="red"]style="float: left;"[/COLOR]>Second</div>
[COLOR="red"]<div style="clear: both;"></div>[/COLOR]
</div>[/CODE]


Making the block elements render inline:
[CODE]<div>
<div id="1st" [COLOR="Red"]style="display: inline-block;"[/COLOR]>First</div><div id="2nd" [COLOR="red"]style="display: inline-block;"[/COLOR]>Second</div>
</div>[/CODE]


Or simply using an inline element:
[CODE]<div>
<[COLOR="red"]span[/COLOR] id="1st">First</[COLOR="red"]span[/COLOR]><[COLOR="red"]span[/COLOR] id="2nd">Second</[COLOR="red"]span[/COLOR]>
</div>[/CODE]
×

Success!

Help @scottjsn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...