I have read similar questions but still have some confusion and asked.
Premise
According to the HTML Standard, the p
element represents a paragraph.
4.4.1 The p element
The p element represents a paragraph.
And the HTML Standard's explanation for paragraphs reads as follows:
A paragraph is typically a run of phrasing content that forms a block of text with one or more sentences that discuss a particular topic, as in typography, but can also be used for more general thematic grouping. For instance, an address is also a paragraph, as is a part of a form, a byline, or a stanza in a poem.
Here, according to NOTE, the p
element is one of several that represent a paragraph. Also, the term paragraph as defined in this section is used for more than just the definition of the p
element.
The term paragraph as defined in this section is used for more than just the definition of the
p
element. The paragraph concept defined here is used to describe how to interpret documents. Thep
element is merely one of several ways of marking up a paragraph.
Furthermore, the following HTML considers text to be a paragraph and states that there are five paragraphs.
<section> <h1>My Cats</h1> You can play with my cat simulator. <object data="cats.sim"> To see the cat simulator, use one of the following links: <ul> <li><a href="cats.sim">Download simulator file</a> <li><a href="https://sims.example.com/watch?v=LYds5xY4INU">Use online simulator</a> </ul> Alternatively, upgrade to the Mellblom Browser. </object> I'm quite proud of it. </section>
- The paragraph that says "You can play with my cat simulator. object I'm quite proud of it.", where object is the object element.
- The paragraph that says "To see the cat simulator, use one of the following links:".
- The paragraph that says "Download simulator file".
- The paragraph that says "Use online simulator".
- The paragraph that says "Alternatively, upgrade to the Mellblom Browser.".
Question 1
The five paragraphs shown in the code contain text. Does this indicate that semantically text also represents a paragraph?
Question 2
The description of the p
element says that the p
element represents a paragraph.
However, the paragraph section says "the p
element is one of several that represent a paragraph" and "the term paragraph as defined in this section is used for more than just the definition of the p
element.
In other words, the paragraph section does not clarify what kind of paragraph the p
element represents. What is the exact definition of the p
element?
CodePudding user response:
question 1: yes
question 2: The p element creates a paragraph, the contiguous section of longer text. However, in HTML, p can be used for any type of contiguous content to be grouped, for example, images or form fields.
CodePudding user response:
I would simply regard p
elements as paragraphs of "plain text content", as opposed to headers, lists, quotes etc. for which there are separate tags in HTML.
Of course you can also create a paragraph using a div
or span
tags defining their styling with CSS (using classes or IDs) and thereby making them look like regular p
paragraphs. Even the "non-paragraphs" in your example which are basically formed by being between two other tags without having a tag of their own as delimiters will look like p
text if their parent container has CSS rules (or just default settings) that is equal or similar to p
tags.
But semantically, only a p
tag is "regular" text content (i.e. not having a function like being a header, part of a list, a blockquote or whatever HTML supplies tags for). If you think in terms of acessibility or SEO, this makes a difference, even if you don't see it.