tibbe
tibbe

Reputation: 9009

Does the CSS block attribute affect HTML well-formedness?

An HTML <body> element can only contain block elements such as <p>. If I declare an inline element such as <span> to be display: block using CSS does that make the following HTML well-formed?

<!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>

Upvotes: 3

Views: 123

Answers (2)

Andy E
Andy E

Reputation: 344567

Did you check to see if it validated (it doesn't)? The specifications for XHTML and HTML only apply to themselves, they don't cross boundaries with CSS specifications much. Thus, there won't be anywhere in the definition that checks the value of the style attribute for a certain CSS property in order to validate a document.

Upvotes: 1

cletus
cletus

Reputation: 625077

<span> is an inline element and not a valid direct child of <body>. The CSS display attribute does not change that.

Upvotes: 4

Related Questions