Is a CSS block attribute affecting the correctness of HTML?

An HTML element <body>can contain only block elements, such as <p>. If I declare an inline element like <span>be display: blockusing CSS, does the following HTML code work correctly?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>Title</title>
  </head>
  <body>
    <span style="display: block;">Hi!</span>
  </body>
</html>
+3
source share
2 answers

<span>is an inline element, not a valid direct child element <body>. The CSS attribute displaydoes not change this.

+4
source

, ( )? XHTML HTML , CSS. , , style CSS .

+1

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


All Articles