开发者

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

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 elem开发者_开发问答ent?


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


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


The p element should not contain any other block element, although it is a block element itself. If you put block elements inside a p, you will, for example, have a hard time trying to apply css rules to those block elements.


It is block, but like any other block element the CSS display property can make it behave in a few ways, including inline or inline-block.


Block level

Source: here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜