Home  >  Article  >  Web Front-end  >  Why can inline elements also add padding attributes_html/css_WEB-ITnose

Why can inline elements also add padding attributes_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:52:511108browse

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


Reply to the discussion (solution)

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


So what’s the point? I’ll give you extra points if you answer again

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn