No newline after div?
HtmlCss FloatNewlineHtml Problem Overview
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?
Html Solutions
Solution 1 - Html
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.
Solution 2 - Html
Have you considered using span
instead of div
? It is the in-line version of div
.
Solution 3 - Html
<div style="display: inline">Is this what you meant?</div>
Solution 4 - Html
Quoting Mr Initial Man from here:
> Instead of this: > >
> > Use this: > > > > Also, you could use this: > >And gostbustaz:
> If you absoultely must use a <div>
,
> you can set
>
> div {
> display: inline;
> }
>
> in your stylesheet.
>
> Of course, that essentially makes the
> <div>
a <span>
.
Solution 5 - Html
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>
Solution 6 - Html
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.
Solution 7 - Html
This works the best, in my case, I tried it all
.div_class {
clear: left;
}
Solution 8 - Html
div.noWrap {
display: inline;
}