I'm wondering how to remove the line break in HTML. For example this code would have two Hello Worlds on top of each other. I'm sorry if I'm not good enough at programming to be in this site.
<p>Hello World</p>
<p>Hello World</p>
“how to remove line break in html” Code Answer's -- One way is to delete the used (if used <br> tags).
You may want to format header tags like H1 and H2 as inline and prevent a break straight after them. Removing padding and margin does not remove the new line. By default, header tags take up all the horizontal space where they appear.
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.
You've got a few options:
p {
display: inline-block;
}
JS Fiddle demo.
Or:
p {
display: inline;
}
JS Fiddle demo.
If it's the white-space between the bottom of the first p
and the top of the second p
that you want to remove:
p {
/* top right bottom left */
margin: 0 0 0 0;
}
JS Fiddle demo.
The <p>
tag is a block-level element, meaning that by default it will try to take the entire width of its container. If you must use a <p>
tag, you can change its behavior with CSS using "display:inline." Although, the <span>
tag might work better for what you need, since it is an inline element by default.
W3Schools has a lot of information you may find helpful.
http://www.w3schools.com/html/html_blocks.asp
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