Reputation: 2212
Is there a way to not have a newline inserted before a div
without using float: left
on the previous element?
Maybe some tag on the div
that will just put it to the right?
Upvotes: 61
Views: 136382
Reputation: 146
Use span instead of div. Since span is inline element while div is the block element. So div is always going to add into the new line as it covers the entire width while span doesn't.
Upvotes: 4
Reputation: 41
This works the best, in my case, I tried it all
.div_class {
clear: left;
}
Upvotes: 0
Reputation: 1573
This works like magic, use it in the CSS file on the div you want to have on the new line:
.div_class {
clear: left;
}
Or declare it in the html:
<div style="clear: left">
<!-- Content... -->
</div>
Upvotes: 3
Reputation: 27201
Quoting Mr Initial Man from here:
Instead of this:
<div id="Top" class="info"></div><a href="#" class="a_info"></a>
Use this:
<span id="Top" class="info"></span><a href="#" class="a_info"></a>
Also, you could use this:
<div id="Top" class="info"><a href="#" class="a_info"></a></div>
And gostbustaz:
If you absoultely must use a
<div>
, you can setdiv { display: inline; }
in your stylesheet.
Of course, that essentially makes the
<div>
a<span>
.
Upvotes: 9
Reputation: 1631
Have you considered using span
instead of div
? It is the in-line version of div
.
Upvotes: 40
Reputation: 490213
There is no newline, just the div
is a block element.
You can make the div
inline by adding display: inline
, which may be what you want.
Upvotes: 95