Why is <hr> and the elements belong to the content stream in html?

I read about content categories from MDN. In the Flow Content section, they say:

Elements that belong to the stream content category usually contain text or inline content.

So, the elements of the contents of the stream must contain something. Now, since we know that the hr and br elements are invalid elements, that is, they do not contain anything. So the question is:

  • Why do the <hr> and <br> elements relate to the content of the stream in html?

Also, I'm rather confused about what streaming content really is? I read about SO about this, for example. the difference between phrasing and flow content is here . As I understand it, the contents of the stream seem to correspond to the elements of the block level, and the contents of the phrases seem to correspond to the built-in elements. More precisely, it seems that Flow Content should be structural content that describes the entire document. For example, section elements, div elements, header , footer and article , etc. The streaming content appears to be some kind of container element or higher level elements, such as the p element, which contains the lower (e.g. text, images and hyperlinks, etc.) of the document.

  • Then why are elements such as <em> , <b> and <i> , etc. included in the streaming content?

Having seen the list of elements of the content of the stream, it seems that every element, but meta content elements belongs to the content stream.

+5
source share
2 answers

You ignore the word usually in the section you specified. Most of them do contain text, but not all of them. Some of them, such as the <br> and <hr> elements that you specified, do not contain anything (and, therefore, are not typical elements of the stream's contents).

The HTML5 specification defines the contents of a stream by saying:

Most of the elements that are used in the body of documents and applications are classified as flow content.

Stream content includes metadata, headings, sectioning elements, interactive elements, phrases, and inline content. This is not limited to elements that contain text.

As I see it, the contents of the stream are all that can be a child of a <body> ; this is the content that flows inside the body .

You can have a <div> element next to a <select> element, which in turn can be next to a <br> element, which can be next to any other element in the stream's content. We can say that these elements flow with each other. Using the definition of “steady, continuous stream or sentence of something,” (the second noun in the Oxford English Dictionary), we can say that these are a continuous and continuous stream of HTML elements.

On the other hand, the <option> , <optgroup> and <li> elements are not streaming content and equally cannot be children of the <body> element. You cannot have an <optgroup> element next to an <hr> element (since the <optgroup> element must be a child of the <select> element) - so we can say that these elements do not flow with the child <body> elements.

+3
source

The answer to both questions is that any element that is an element of phrasing is also considered to be streaming content, as necessary, since elements whose content model is “streaming content” may also contain phrase elements.

As for <hr> , the reason it’s a stream item, not a phrasing item, is because of its definition

The hr element represents a topic break at paragraph level

Since it is intended to separate paragraphs within a section, which in HTML is represented by a <p> stream element, it makes sense for <hr> be a stream element rather than a friction element.

The content model of both elements does not matter. This is the content model of their parent elements, which is relevant here. The statement provided by MDN is informative and not intended to be accepted de jure; indeed, this statement is not displayed in either the W3C HTML format or the WHATWG HTML.

0
source

Source: https://habr.com/ru/post/1258749/


All Articles