Skip to main content

What is the advantage of DIV over P?

There are different kinds of elements (block, inline, table...).

Example for block elements are: h1, p, div, ...

Examples for inline elements are: em, block, span, ...

An block element can contain inline elements and text. Some block elements can contain also other block elements (like div) while others cannot (like p). Block elements start a new line in the text flow.

Inline elements can contain other inline elements and text but not block elements. Inline elements do not start a new line in the text flow.


Since <p> is an block element which should not contain other block elements you shouldn't use a <div> inside. Use the <span> here.

You can't use the div there legally. It's a block element. Span is inline.
Source: Stackoverflow

Comments

Popular posts from this blog

15 Movies That Made Audiences Leave The Theater

15 Movies That Made Audiences Leave The Theater : Source:  Screenrant Forking over an hour or two of pay makes going to see a film a burden on the wallet, even if theater chains maintain that it's cheaper than ever to go to the movies. Most moviegoers want to see a film they know they will enjoy to avoid throwing away their hard-earned cash, so when movies sometimes leave audiences feeling disgruntled, disgusted or even ill enough to walk out, it's a big deal. Even some of the staunchest movie-goers who refuse to leave the theater for any reason sometimes find themselves walking out of a production for the strangest excuses. Whether or not the theater will refund tickets paid for movies that upset or sicken audiences, hundreds of people have walked out of startling films for plenty of reasons. Sometimes it's mind-boggling. For those who wanted a scary movie, why bail when it gets too scary? Whatever happened to turning your head? Then there are the people who never re...

The 10 greatest living scientists in the world today

Ranking the world's greatest contemporary scientists may be a no-win proposition, with inevitable questions about how to evaluate one's contribution over another. How does a discovery in one field measure up to a discovery in a different one? And what about Richard Dawkins, where is he on this list? All reasonable questions, but ultimately we need to start the discussion somewhere. So here's a debatable list of top ten scientists from around the world who have made a great impact on our life (but not in order of the magnitude of their achievements because that just might be an unscientific exercise): 1. Timothy Berners-Lee It would be hard to argue against the guy who invented a little something called “the world wide web" being on this list. Timothy Berners-Lee is a British computer scientist, knighted by the Queen Elizabeth II for his pioneering work. He is especially famous for his proposal to share information by using the technology of hypertext, the cornersto...

Why you should watch movies and TV shows with subtitles on

Lately I've been watching more movies and TV shows with subtitles on. And I'm really into it. It started out of necessity. Too often I'd find myself missing what somebody was saying on the screen, especially during those quiet-but-crucial moments in movies and shows. Adding subtitles negated the need for rewinding over and over again. But when I kept the subtitles on, even when I didn't need to rewind for that moment I missed, I found myself catching more details than ever before. I was learning character names, and their proper spellings. I was catching important lines said off-screen. I was catching song lyrics. Reading the words on screen gave me a new level of comprehension, even for shows or movies I've seen more than once. I could actually see the names of diseases, and medicines, and procedures while watching medical dramas. Plots became generally easier to follow. And I grew an appreciation for shows that were well-written — seeing the script for ...