Community Forum 2

 

Question

The element in this exercise 1.5k contains text but can elements contain other types of content? If so, what types of content might an HTML element contain?

Answer

It depends on the element. As you will learn, <p><div>, and <span> elements can contain text whereas elements like <ul> or <ol> should only contain <li> elements as direct children.

Block level tags like the <div> can contain all tags that can exist within the <body> (in other words, we can nest other elements within a <div>) whereas self-closing tags like <img> can not contain any content at all!



Question

In this example 828, 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.



Question

In the example given in this exercise 506, we use the <p> tag even for a two word sentence. Do finer granularity elements exist? For example, is there a sentence or a word element?

Answer

While a sentence or a word element does not exist, a developer who wanted finer control over a piece of a paragraph like a word, sentence or character might use an element like <span><em>, or <strong> to more specifically target content. You will learn about each of these tags and their use cases in the exercises to come. For now, just know that they exist and can be used to target sentences, words, or characters within a paragraph or even to target entire paragraphs within larger articles. In other words, developers can use these tags to control the granularity of the targeted content.



Comments