Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct way to include a blank line in an html list element?

Tags:

html

css

Assuming I have a list:

  • Item One
  • Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs. I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.
  • Item Three

What is the correct way to achieve this in HTML/CSS:

  • Item One

  • Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs.

    I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.

  • Item Three

It seems some options are <p>, <div>, and perhaps <span> with the appropriate display style. There are probably even more options, but I am hoping there is a correct / recommended approach.

For the sake of scoping this question, let's assume modern browsers that support HTML5/CSS3.

Edit: For people voting to close the question, could you leave a comment as to why? If there's some obvious guideline I should follow, please link to it. Given that there are often multiple ways to accomplish things in HTML/CSS, I think it's fair to ask if there is a "correct" way.

like image 849
Jedidja Avatar asked Feb 10 '16 12:02

Jedidja


People also ask

What is a \n in HTML?

The \n character matches newline characters.

How do you add a blank line in CSS?

Just use margin-top: 1em; that will give a white space of one line above your tag .

Which tag insert a blank line before and after the text?

With <p> and <blockquote> tags, a single blank line appears before and after the enclosed indented text block. When <br /> tags are inserted to end lines of text, no spacing appears between the lines.


2 Answers

<p> stands for paragraph, so this would be the recommended way, but, all the other ways are valid as well.

like image 102
Itay Gal Avatar answered Oct 07 '22 15:10

Itay Gal


<span> is not recommended as it's not a block element.

You can use <br> to breakline:

<ul>
  <li>
    Item One
  </li>

  <li>
    Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs.
    <br><br>I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.
  </li>
  <li>
    Item Three
  </li>
</ul>

You can as well us an empty block element and set a size to it using CSS:

.spacer {
  height: 10px;
}
Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs.
<div class="spacer"></div>I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.

Or a <p> tag:

    <p>Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs.</p>
    <p>I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.</p>
like image 32
Magicprog.fr Avatar answered Oct 07 '22 16:10

Magicprog.fr