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?
display:inline; will turn the div into the equivalent of a span . It will be unaffected by margin-top , margin-bottom , padding-top , padding-bottom , height , etc.
Use margins or padding to create space, rather than <br> tags. Oh yes the margin-bottom should work. That's it! PS: If you put the “linebreak” class into an inline element (e.g a span) you need to add “display:block” into your code.
It is an inline-level element and does not break to the next line unless its default behavior is changed. To make these examples easier to use and understand for all types of computer users, we're using the style attribute in the div.
The white-space property has numerous options, all of which define how to treat white space inside a given element. Here, you have set white-space to nowrap , which will prevent all line breaks.
No newline after div? 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? 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.
A DIV is by default a BLOCK display element, meaning it sits on its own line. If you add the CSS property display:inline it will behave the way you want. But perhaps you should be considering a SPAN instead?
I have many times succeeded to get div's without line breaks after them, by playing around with the float css attribute and the width css attribute. Of course after working out the solution you have to test it in all browsers, and in each browser you have to re-size the windows to make sure that it works in all circumstances.
Because they're block elements, when reducing the size of Div one to make room for the other div, you're left with space next to Div one and Div two below Div one. To move the div up to the next line both div's need to have the inline-block display setting as shown below.
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.
Have you considered using span
instead of div
? It is the in-line version of div
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With