vs
in clearing

后端 未结 12 1395
醉话见心
醉话见心 2021-02-02 10:47

What is the difference


vs

??

Al

相关标签:
12条回答
  • 2021-02-02 11:20

    You do need to be careful about the / on the tag.

    I had problems with the slash on the <script> tag terminated by <script language="javascript" src="MyScripts.js" /> way. Although, most xml compliant parsers would accept both.

    <script> has to be terminated by </script>

    0 讨论(0)
  • 2021-02-02 11:26

    <br /> is an inline element, where as <div> is a block element. Anyway, I personally prefer to use <hr class="clear">, I feel it is more semantically adequate.

    0 讨论(0)
  • 2021-02-02 11:27

    This is what I always use:

    <style type="text/css">
    .clearing {
    height: 0;
    line-height: 0;
    font-size: 0;
    clear: both;
    overflow:hidden;
    }
    </style>
    

    And where I need a clearing:

    <div class="clearing"></div>
    

    You may also be interested in self-clearing containers: http://www.positioniseverything.net/easyclearing.html

    EDIT: Added "overflow:hidden" per the suggestion from another answer poster.

    0 讨论(0)
  • 2021-02-02 11:33

    All methods are bad. Use CSS to change the appearance of your page. There are many methods to accomplish the same with CSS. Such as giving "overflow: hidden;" on the parent element.

    0 讨论(0)
  • 2021-02-02 11:37

    This is the style that I use for clearing:

    .Clear { clear: both; height: 0; overflow: hidden; }
    

    Usage:

    <div class="Clear"></div>
    

    This will not take up any extra space in the page as the height is zero.

    Internet Explorer has a strange idea that the content of each element has to be at least one character high, and another strange idea that each element should be as high as it's content. Using overflow: hidden keeps the content from affecting the size of the element.

    0 讨论(0)
  • 2021-02-02 11:37

    If you're writing (valid) XHTML you don't need to use the closing tag, but self closing div tags don't work in all browsers, so you should still use it. ie your example:

    `<div style="clear:both;"> </div>`
    

    This is valid XHTML (see html vs xhtml) but doesn't work in all browsers, so you should stick with the above:

    <div style="clear:both;" />

    also, For what it's worth the <br> tag is deprecated in favor of the <line> tag (see w3.org entry on the <br/> tag)

    0 讨论(0)
提交回复
热议问题