Home > Article > Web Front-end > Why can inline elements also add padding attributes_html/css_WEB-ITnose
I saw something written like this in a code as shown in the picture
The attribute of the a tag actually says padding. My understanding is that padding is used for those block elements or things that are converted to block elements. The a tag here is not converted to a block. Why can the attributes of the block element be used? It is puzzling
Both block-level elements and inline elements can use padding. However, the padding of inline elements only affects the left and right sides.
Both block-level elements and inline elements can use padding. However, the padding of inline elements only affects the left and right sides. Effect
a tag can be designated as a block element
a{display:block}
It will be useful to set padding in this way
You can also set it to inline-block
If it is the default a element, in some browsers, the setting of the padding attribute is valid. Invalid in browsers
You can set all elements to block elements or non-block elements through display
Don’t always think that the a element must not be a block element, and don’t always think that a div must be a block element.
I don’t think it’s puzzling
You should look at the performance of the page. Does the padding work?
It doesn’t work. Why doesn’t it work?
Does it work? Why does it work?
This is how to observe similar problems.
I don’t think it’s puzzling
You should look at the performance of the page. Does the padding work?
It doesn’t work. Why doesn’t it work?
Does it work? Why does it work?
This is how to observe similar problems.