Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a native inline-block HTML 'container' element?

Tags:

html

xhtml

A span is an inline element and div is a block element. Is there a 'native' (X)HTML / HTML5 inline-block element that can act like a container? (Without applying CSS)

Definitions:

block
This value causes an element to generate a block box.
inline-block
This value causes an element to generate an inline-level block container. The inside of an inline-block is formatted as a block box, and the element itself is formatted as an atomic inline-level box.
inline
This value causes an element to generate one or more inline boxes.

like image 388
Kees C. Bakker Avatar asked Jan 09 '12 14:01

Kees C. Bakker


People also ask

Can I make a block element inline?

You can set a block-level element to display like an inline element by setting the display property to inline. You can also cause inline elements to behave like block-level elements using the display property.

Which HTML elements are inline by default?

YES there is an element that defaults to inline. The answer is the span element.

Is div inline or block?

div is a “block element” (now redefined as Flow Content) and span is an “inline element” (Phrasing Content).


3 Answers

No, there is not. You have to specify inline-block explictly.

like image 53
Crozin Avatar answered Sep 24 '22 20:09

Crozin


Strictly speaking <button> fulfils the criteria set. HTML5 says

When the button binding applies to a button element [which it ordinarily does], the element is expected to render as an 'inline-block' box rendered as a button whose contents are the contents of the element.

However while it is a container element that has a default inline-block rendering, it is not a General Purpose container so can't be used for anything but as a button.

like image 39
Alohci Avatar answered Sep 24 '22 20:09

Alohci


iframe is also inline-block too

like image 21
Kernel James Avatar answered Sep 21 '22 20:09

Kernel James