Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove line break HTML [closed]

Tags:

html

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>
like image 559
Ptr13 Avatar asked Aug 09 '13 21:08

Ptr13


People also ask

How do you remove a line break in HTML?

“how to remove line break in html” Code Answer's -- One way is to delete the used (if used <br> tags).

How do you prevent a line break with an H1 H2 h3 tag?

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.

How do you remove a line break in CSS?

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.


2 Answers

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.

like image 168
David Thomas Avatar answered Oct 03 '22 09:10

David Thomas


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

like image 24
user1171848 Avatar answered Oct 03 '22 07:10

user1171848