Home > Back-end >  Is typing <meta newline content ok?
Is typing <meta newline content ok?

Time:10-14

I'm just wondering.

Is the first just fine or is it really required to write it as the second?

<meta name=""
      content="" />

<meta name="" content="" />

CodePudding user response:

As Mozilla says, HTML renderers largely ignore whitespace while rendering, although the DOM represents them as unrendered text nodes.

HTML largely ignores whitespace?

In the case of HTML, whitespace is largely ignored — whitespace in between words is treated as a single character, and whitespace at the start and end of elements and outside elements is ignored.

...

Any whitespace characters that are outside of HTML elements in the original document are represented in the DOM. This is needed internally so that the editor can preserve formatting of documents.

This means that:

  • There will be some text nodes that contain only whitespace, and
  • Some text nodes will have whitespace at the beginning or end.

https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace

There is also the pre tag, which respects whitepace (in various modes) found within it in the source document. CSS can also introduce visible whitespace styling in the viewport in various ways as the document is rendered, as well.

CodePudding user response:

You can use both. Have you tried to use both too?

  • Related