Question:I also have a question about paragraph tags. Since we encapsulate the IMG tag within PARAGRAPH tags , why don't we also encapsulate list tags within paragraph tags? When should we encapsulate a tag within paragraph tags and when should we not?
These are good questions. You are quite right to note that an IMG does not have to be a part of another element; it can stand alone. But IMG tags do not usually have any CSS instructions, so I guess I was thinking that without any additional instruction to the IMG, it just sits to the left on the page. But if it is fitted within a P, then it can inherit the CSS instruction for a P and display accordingly.
But better yet is to create a CSS class that you may apply to an IMG, thereby controlling exactly how the IMG will display.
An unordered list, and its subordinate LIST ITEMS, on the other hand, usually do have some CSS instructions and so display accordingly. They are the equivalent of a special purpose type of paragraph and do not need to be inside a paragraph element.
An example of the use of CSS instructions with IMG tags can be seen on http://ils.unc.edu/courses/2014_fall/inls161_001/sessions.02.09a.editors.intro.html
Lines 275-280 are an IMG standing alone. (I removed the < before it and the > after it so it would display)
|alt="our home page code as seen in Notepad++" /|
But the “class” attribute points to a specific class in the linked stylesheet (http://ils.unc.edu/courses/2014_fall/inls161_001/css/161style.css )
On lines 399-403, a class named “center” is defined.
margin: 20px auto;
So when I want an IMG to display in the center of a space, I use this class as an attribute-value pair in association with a tag, in this case, an IMG tag. When I need it to display in the left with the text wrapped, I use the class=”left”, and so forth.
So, your question is a good one and opens up an extended conversation.