I cannot change the width of <a> without making it float or block

Why is this so?

What is the reason inside?

+3
source share
3 answers

When you swim, you implicitly make it a block element. And unlike inline elements ( a , included in their number), block elements can be assigned width and height. Here's a good explanation of the differences between blocks and inline differences .

Edit: removed "have a layout" as part of the description of the elements of the block, this one is not quite right. ...

+3
source

<a> . , "" .

CSS display: inline-block - , , /.

+3

The package is incorrect.

use the built-in unit

<a href="" style="display:inline-block; width:100px;  background-color:Red;">abc</a>
+1
source

Source: https://habr.com/ru/post/1722751/


All Articles