Do tags themselves count as content?

Question

In this example, do the <p> tags also count as content or is the content just the sentence contained within the tags?

Answer

The content is just the information contained within the tags themselves. The tags are marking up this content so that the browser knows how to properly interpret and structure this information. As you will learn later in this lesson, the content is not always contained within an opening and closing tag. For example, the <img> tag is an example of a self-closing tag and it introduces content into the page differently than the <p> element.

18 Likes

should be than not then

3 Likes

Thank you for pointing that out. Fixed.

1 Like

can someone tell me if this is right so the < p > element can only contain text or can it contain images too? and also it said it the last question that tags like images can’t contain content at all is this because after you finish your content you use the < IMG > to finish the content off? thanks guys in advance

3 Likes

A paragraph may contain any inline level element. B, I, STRONG, EM, SPAN, INPUT, BR, HR and IMG are among such elements. (Check up on BR and HR as to whether block or inline.)

In the old days we used to have an unwritten rule… “No inline elements in the BODY.” That means an IMG would necessarily be contained in either a DIV, an LI or a P. I still recommend containing images, even if this rule is flouted in present day.

An IMG element is known as a void element since it is not a content container. It’s content is written to attributes on the element. For IMG, this would be the src, title and alt attributes.

26 Likes

so does that mean that <body></body> is not the content of <html></html>?

No. BODY is a child of HTML. All the content the user sees is contained in it.

3 Likes

Is a nested element can be content? Like this <div><h1>Hello World!</h1></div> . Is h1 tag can be content for div?

None of the tags are content, unless we consider RAW TEXT. HTML is text from end to end. However, we should consider what the user is being delivered as the actual content.

Hello World!

would be the content above. Search engines strip away all the HTML to arrive at the textual content we are delivering to our audience. The way they classify and index the page will be based largely upon what is left over. Tags are markup that we assign to content to give it structure and importance. Search engines also see that (as do assistive technologies) but use it only as a guide.

Say we have a report that we’ve composed. That is the content. How we mark up that content is arbitrary, as in we decide how to declare each part of the report.

5 Likes

An HTML Element is defined as a piece of content in an HTML Document.
A Tag defines the content by its function and is part of the HTML Element.
Tags cannot be considered content on a webpage because they aren’t visible.
Tags are content only in the context of an HTML Document because of their constituent properties.
Basically Tags include content that is to be interpreted by the viewer (you and me) and an Element contains content that is to be interpreted by the computer.

6 Likes

No. Tags themselves are not counted as contents.