Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is <p> a block-level or inline-level element?

Tags:

html

I had a question when I came across the HTML 4.01 DTD: In the strict DTD, a <p> element is defined as <!ELEMENT P - O (%inline;)* -- paragraph --> but I thought that <p> was a block-level element, and all (maybe almost all) user agents define <p> as a block-level.

So is <p> a block-level or inline-level element?

like image 239
Andor Avatar asked May 07 '10 15:05

Andor


People also ask

Is P block on inline block?

Paragraphs are block-level elements, which means that they block off a whole line for themselves, and images are inline elements, which means they will automatically be placed next to one another on the same line. Block-level elements that you've seen so far include: Headings. Paragraphs (p)

Which elements are block level?

Block-level Elements Two commonly used block elements are: <p> and <div> . The <p> element defines a paragraph in an HTML document. The <div> element defines a division or a section in an HTML document. The <p> element is a block-level element.

Is an h1 block or inline?

They are block elements.

What is the difference between inline and block level elements?

By default, inline elements do not force a new line to begin in the document flow. Block elements, on the other hand, typically cause a line break to occur (although, as usual, this can be changed using CSS).


2 Answers

It is a block level element. What that DTD is saying is that <p> tags can only contain inline elements.

like image 74
nickf Avatar answered Sep 18 '22 19:09

nickf


Of course it is.

The following are defined as block-level elements in XHTML 1.0:

* address - Address * blockquote - Block quotation * center - Centered block * dir - Directory list * div - Generic block-level container * dl - Definition list * fieldset - Form control group * form - Interactive form * h1 - Level-one heading * h2 - Level-two heading * h3 - Level-three heading * h4 - Level-four heading * h5 - Level-five heading * h6 - Level-six heading * hr - Horizontal rule * isindex - Input prompt * menu - Menu list * noframes - Frames alternate content * noscript - Alternate script content * ol - Ordered list * p - Paragraph * pre - Preformatted text * table - Table * ul - Unordered list 

The following elements may also be considered block-level elements since they may contain block-level elements:

* dd - Definition description * dt - Definition term * frameset - Frameset * li - List item * tbody - Table body * td - Table data cell * tfoot - Table foot * th - Table header cell * thead - Table head * tr - Table row 

The following elements may be used as either block-level elements or inline elements. If used as inline elements (e.g., within another inline element or a p), these elements should not contain any block-level elements.

* applet - Java applet * button - Button * del - Deleted text * iframe - Inline frame * ins - Inserted text * map - Image map * object - Object * script - Client-side script 

More Info Here

like image 23
Sarfraz Avatar answered Sep 20 '22 19:09

Sarfraz