natsuki_2002
natsuki_2002

Reputation: 25359

CSS: paragraph in div to appear on same line as div text

How can I get "Current data: " and whatever value the #dataset_name paragraph takes to appear on one line?

<div id="current_data">Current dataset: <p id="dataset_name"></p></div>

thanks!

Upvotes: 0

Views: 90

Answers (3)

max
max

Reputation: 102423

Why not

<p id="current_data">Current dataset: <span id="dataset_name"></span></p>

It makes more semantical sense (as long as its not really a table).

Upvotes: 1

Alejandro Iv&#225;n
Alejandro Iv&#225;n

Reputation: 4061

Try to use:

<div id="current_data">Current dataset: <span id="dataset_name"></span></div>

Spans are, by default, inline elements, p and div are block elements (therefore, they add a "newline"). You could also use <p style="display: inline;">...</p>, but it's better to use span in these cases.

Upvotes: 3

Deryck
Deryck

Reputation: 7668

<p> elements are considered blocks by HTML while normal text is inline.

In your CSS put:

p {
  display: inline;
}

and you'll be good.

Upvotes: 2

Related Questions