DarkKnightFan
DarkKnightFan

Reputation: 1953

html display div in same line

I wish to display a text on my jsp page:

Sample date: <div id="sampleDate"/>

So I want it to be displayed as Sample date: 29-Aug-2012

But it is coming up like this:

Sample Date:

29-Aug-2012

Can anyone help me with this?

Upvotes: 3

Views: 9366

Answers (3)

user1317647
user1317647

Reputation:

css for sampleDate should be

#sampleDate { 
   display:inline;
}

Also you could use float:left; for Sample date: and for #sampleDate block float:right; put both blocks inside other block and set width ( then there wont be a huge space between these two )

Upvotes: 2

andrewk
andrewk

Reputation: 3871

You can use css ​#sampleDate{display:inline;}​. But you should use @Dipaks method, by using a span tag.

View live here http://jsfiddle.net/WkNp8/1/

Upvotes: 0

Dipak
Dipak

Reputation: 12190

Write it as -

Sample date: <span id="sampleDate"></span>

I won't recommend this but still if you want to keep DIV then you have to make it inline element -

Sample date: <div id="sampleDate"></div>

#sampleDate{ display: inline; }

Upvotes: 3

Related Questions