Div instead of <p>

When I was doing CSS course I saw this:
.div class=“description”>The Korean capital is a city of contrasts. Fourteenth-century city gates squat in the shadow of 21st-century skyscrapers, while the broad Han River is back-dropped by granite mountains rising in the city centercomplete with alpine highways speeding around their contours and temples nestling among their crags. Fashionable, gadget-laden youths battle for sidewalk space with fortune-tellers and peddlers, while tiny neighbourhoods of traditional cottages contrast with endless ranks of identical apartments.
There was no <p. tags, why is that.

Hello @mr.want.to.learn,

If you mean that div tag was used to markup this content, instead of p tag,
then I don’t know why was this done.

Doing this is not a good practice.

If one has to make container use div but if one wants a paragraph then p tag must be used.

Check this out

I hope that this will help you.

1 Like

Oh ok and thank you for the fast reply. :smiley:

In HTML there are no rules, only recommendations. The specification does not dictate how we should mark up a document, only how certain tags should work.

Take for instance white space. Browsers ignore it, for the most part so it has no particular meaning or value beyond making the document source code more readable.

<div></div> and <p></p> are both block level elements with one exception… dimensions and margins. DIV has no predefined dimensions and no margin by default. P does have a predefined default height, 1em and predefined bottom margin, also 1em. Apart from that they are both just containers and that is how the browser sees them. Whether P or DIV it will render the content the same way.

If a DIV is used instead of a P, no rule has been broken. We need first to realize this.

Now when it comes to well-formedness and standards, particularly accessibility there are guidelines to follow that can aid a search engine or screen reader in interpreting the semantics of the document. Again, no rules, only guidelines. The final choice is still left up to the author.

A well formed document will follow the dictates of a good outline, the same way one would be followed when writing an essay. A good outline describes the document content without having to read the contained topics, only their headings and placement/arrangement.

When one is just beginning to learn the ins and outs of markup the last concern that enters our mind should be "rules’. Learn how the tags work, and what their general intended purposes are. That’s enough to know, for now.

<div class="description">text description of some object relative to this division</div>

There is nothing that says this is a bad practice. In fact it is very explicit what purpose it serves and can even be targeted by the CSS or JS by its class name to style or add effects. Markup by itself has very few side effects since it is static, and not dynamic.

The nature of the document will dictate its structure and page elements. This is subjective and left entirely up to the author. There are no markup police, only validators that check for errors in composition such as missing ENDTAGs, deprecated attributes or tags, tag chaining, and so on. Accessibility checkers compare the document to the set of guidelines to look for areas of concern. It’s still up the author to sign off on their finished product.

Bottom line, there are no rules, only recommendations and guidelines. The less time we spend getting hung up on minor details the more time we can spend learning how to be objective with our own creations.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.