Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do <span> elements with "position: absolute;" behave as block-level elements?

Are <span> elements with position: absolute; able to have a height, width, padding, etc. without changing it to display: block; or inline-block;?

It seems to work, but is it ok with all browsers to omit display: block/inline-block for a <span> element with position: absolute;?

like image 299
Sunny Avatar asked Jan 20 '26 11:01

Sunny


1 Answers

The spec says yes:

Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned, the computed value of 'float' is 'none', and display is set according to the table below. The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and the box's containing block.

The table says that any inline display values (inline, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table-row, table-cell, table-caption, inline-block) become block.

like image 124
SLaks Avatar answered Jan 22 '26 04:01

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!