No newline after div?

HtmlCss FloatNewline

Html 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;
    }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOliverView Question on Stackoverflow
Solution 1 - HtmlalexView Answer on Stackoverflow
Solution 2 - HtmlMatthew SantView Answer on Stackoverflow
Solution 3 - HtmljerlucView Answer on Stackoverflow
Solution 4 - HtmlMateen UlhaqView Answer on Stackoverflow
Solution 5 - HtmlJonasView Answer on Stackoverflow
Solution 6 - HtmlShah HassanView Answer on Stackoverflow
Solution 7 - Htmluser2231096View Answer on Stackoverflow
Solution 8 - HtmlAndrewView Answer on Stackoverflow