Is necessary to show an empty
?

后端 未结 7 1717
天涯浪人
天涯浪人 2021-01-17 10:25

I\'d like to show a div that has a background-color with the height and width set to 100% but no content. Is it possible to do that without putting a   inside?

7条回答
  •  被撕碎了的回忆
    2021-01-17 10:46

    Hmmm... I'm not sure what exactly the specs say, but I know that while empty inline-elements (e.g. span) are valid, empty block-elements (e.g. p or div) get "cleaned up" by html-tidy.

    Thus I'd say it's safer to stick to the   as it does no harm in your case. I'd also add a comment like "" or something like that. So everyone who's going to change your html knows that the div has a special meaning even though it's empty.

提交回复
热议问题