且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

关闭HTML标记

更新时间:2023-12-05 21:01:46

如果您的DOCTYPE设置为XHTML,则只能使用自闭标签<div />,因为它是从XML借来的,您可以在其中使用自闭标签.如果您的DOCTYPE设置为HTML 4.01或HTML 5,则无法使用它.

You can only use a self closing tag <div /> if your DOCTYPE is set to XHTML as this is borrowed from XML where you can have self closing tags. You can't have it if your DOCTYPE is set to HTML 4.01 or HTML 5.

http://www.w3.org/TR/xhtml1/

我不确定您是否确实希望使用此功能,但是,如果要清除浮点,则可以执行此操作,而不必担心兼容性问题,尤其是在IE进入仿真模式的情况下.

I'm not sure your exact use case for wanting this, but if it's for clearing floats, you can do this instead and not have to worry about compatibility issues, especially with IE if it kicks into emulation mode.

<style type="text/css">
.clear-fix {
    clear: both !important;
    display: block !important;
    font-size: 0 !important;
    line-height: 0 !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}
</style>
<br class="clear-fix" />