Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is space legal after an angle bracket? [duplicate]

Tags:

html

xml

I'm building a slicer for deserializing html and xml. The question is - is it legal in either language to put a space after angle bracket and still have it count as a tag? For example

< div>

Or should I just consider that plain text?

And yes, I tried searching web for this but even after browsing through w3, I couldn't spot an explicit answer.

like image 356
user81993 Avatar asked Oct 03 '14 00:10

user81993


People also ask

Are spaces allowed in HTML tags?

An HTML space tag would be convenient for creating spaces, but the fact is that none exists.. The source of the problem is that HTML compresses all space characters—tabs, spaces, and carriage returns—to one character. If you want to indent your paragraphs, you can't simply type five spaces and then begin the text.

How does an angle bracket work?

Usage of angle bracketsIn some languages, a double set of angle brackets may be used in place of quotation marks to contain quotes. In English, they may be used informally to insert asides, indicate speech in a foreign language, or to mention a website, but all of these uses are rare even in informal writing.

How do you escape an angle bracket in HTML?

Left angle brackets are used to start tags; ampersands are used to denote HTML entities. If you want to use them as literal characters, you must escape them as entities, e.g. &lt; , and &amp; . in your anchor tag href attribute.

What does an angle bracket mean?

What Does Angle Bracket Mean? The angle bracket (< or >), which is also called an “inequality sign” for its use in mathematics, is a kind of sideways caret that can be used to include tags or pieces of code. This ASCII set of characters is common in web design and other types of coding projects.


1 Answers

The HTML spec from WHATWG indicates the opening bracket must be immediately followed by the tag name.

The XML spec from W3C has the same requirements.

You may not have space leading the tag name. However, there can be any amount of space between the end of the tag name and the closing bracket. The following is valid:

<p           ></p         >
<p
></p>
like image 112
Taylor Buchanan Avatar answered Sep 19 '22 06:09

Taylor Buchanan