Reputation: 187
My question is, how do I avoid having the text on a new row?
My code:
<html>
<body>
<p >Seating availability.</p>
<p ><div style="width: 10px; height: 10px; background-color: green; border: 0px;" ></div> There are available seats.</p>
<p ><div style="width: 10px; height: 10px; background-color: yellow; border: 0px;" ></div> Available seats are decreasing.</p>
<p ><div style="width: 10px; height: 10px; background-color: orange; border: 0px;" ></div> Less than 15% of seats available.</p>
<p ><div style="width: 10px; height: 10px; background-color: red; border: 0px;" ></div> There are no available seats.</p>
</body>
</html>
How should I code this?
Upvotes: 10
Views: 32947
Reputation: 160
add display: inline-block to div
<html>
<head>
<style>
div
{
display: inline-block;
}
</style>
</head>
<body>
<p >Seating availability.</p>
<p><div style="width: 10px; height: 10px; background-color: green; border: 0px;" ></div>There are available seats.</p>
<p ><div style="width: 10px; height: 10px; background-color: yellow; border: 0px;" ></div> Available seats are decreasing.</p>
<p ><div style="width: 10px; height: 10px; background-color: orange; border: 0px;" ></div> Less than 15% of seats available.</p>
<p ><div style="width: 10px; height: 10px; background-color: red; border: 0px;" ></div> There are no available seats.</p>
</body>
</html>
Upvotes: 9
Reputation: 43
Put this code in your css file
div {
margin: 5px 10px 0 0 ;
float:left;
}
Upvotes: 0
Reputation: 17366
There are so many display
properties are available:
Try using display:inline-block;
div style="width: 10px; height: 10px; background-color: green; border: 0px;display:inline-block;" ></div>
Hope this helps!
Remove <p></p>
tag just use <div>
as <p>
is always takes new line.
Upvotes: 4
Reputation: 68
Use span instead of div and add (display:inline-block;) paragraph (p) Can't Contain (div) but can contain (span) ' Seating availability.
There are available seats. Available seats are decreasing. Less than 15% of seats available. There are no available seats. 'Upvotes: 1