Is the declaration really declared as an inline element in a block?

I passed the stylesheet with the following W3C validator and passed:

a { display: block; } 

So, you want to make sure that this is a valid markup for using an inline element as a single block? I know this will work, but is it really?

thanks

+4
source share
5 answers

Yes, it is fully valid. And useful too.

One small note (since the above answer is very short), this method of styling usually inline elements as block elements is quite common. For example, when creating a horizontal navigation menu from a list, you often see <a> elements created with display:block so that links can take the full width and height of the parent list element.

+5
source

Yes, it is valid, but you can also use inline-block to use the inline element while maintaining the properties of the block.

+3
source

Yes it really is.

There are elements, as you know, built-in or blocked by default. But it is perfectly valid to then go over and override this in CSS.

+2
source

Yes , it is valid. However, if you really do not want to do this, you can wrap a in a div . This would be useless, since, since it is completely fair; therefore, the display attribute is.

+1
source

A stylesheet is valid in the sense that it conforms to the CSS specifications. This is a purely formal thing. In CSS, the selector a doesn't really matter; it's just an identifier; CSS has no information about the meaning of a in HTML, such as an inline element, and in fact, a stylesheet can be used to style an XML document, where a means something completely different.

HTML validity, on the other hand, is not CSS dependent at all. This is a formal thing about arent markup and markup.

Whether it is “valid” in some other, informal sense (for example, “good practice” or “useful” or “corresponds to the style guide”) is a different issue, and the discussion is not a technical issue. In any case, display: block usually used for the a element, so that you can set its dimensions as we can do for blocks (for example, so that the link fills the table cell).

0
source

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


All Articles