1

Desired HTML:

<br/>
<form id="contact-form" method="post" action="contact.php" role="form">

My Pug code was:

br 
  form#contact-form(method='post'action='contact.php' role='form')

But it's showing the error:

br is a self closing element: <br/> but contains nested content.

Sean
  • 6,873
  • 4
  • 21
  • 46
  • Possible duplicate https://stackoverflow.com/questions/5433977/what-about-line-breaks-in-jade – Tom Nov 07 '19 at 13:13

2 Answers2

2

If your code is located inside a div, your pug template would have to look like this:

div
   br
   form#contact-form(method='post'action='contact.php' role='form')

From the pug documentation

Remember:

</br> isn't valid, because it's a self closing element.

<br/> and <br> are valid.

Source (MDN)

Tom
  • 4,070
  • 4
  • 22
  • 50
0

Indenting the form underneath the br like you have in your code—

// incorrect
br
  form

—tells Pug you're trying to create this HTML—

<br><form></form></br>

—which is invalid because line-break elements can't contain other elements.

Instead, place the line-break at the same indentation level the form, which tells Pug they should be siblings, like this—

// correct
br
form

—which will compile to:

<br>
<form></form>
Sean
  • 6,873
  • 4
  • 21
  • 46