Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are line breaks allowed inside html tags?

Tags:

html

Is it allowed to have a line break inside a html tag? For example:

<h1
id="heading">

A first test in Chrome shows that this works, but is it specifically allowed by the spec and do all browsers (especially email clients) parse this correctly?

And what about in attributes?

<h1 
class="one
two">

In this case, will it be interpreted as a space?

(This last case is not answered in the "possible duplicate question")

like image 562
Peter Smit Avatar asked Apr 08 '15 08:04

Peter Smit


People also ask

Is tag used for line break in HTML?

The <br> HTML element produces a line break in text (carriage-return).

Does HTML care about line breaks?

You can insert line breaks in HTML with the <br> tag, which is equivalent to a carriage return on a keyboard. Be aware that HTML will ignore any line break from a keyboard's return key. If you are wondering why there's a forward slash in the <br> tag above, the slash was important when HTML4 was still widely used.

How do you do a line break in HTML?

To add a line break to your HTML code, you use the <br> tag. The <br> tag does not have an end tag. You can also add additional lines between paragraphs by using the <br> tags. Each <br> tag you enter creates another blank line.

Is line break an empty tag?

The HTML <br> tag is used for representing a line break. The <br> tag is an empty tag. In other words, it has no end tag (i.e. only use the opening tag <br> ).


1 Answers

yes that is acceptable! The browser will ignore line breaks and will teat them as spaces. So in you second example you will have an h1 element with two classes as attributes.

So

<h1 
class="one
two">

is the same as

< h1 class="one two">
like image 68
MaVRoSCy Avatar answered Sep 28 '22 19:09

MaVRoSCy