«

»

Oct
25

Browser display wrongly when handling empty element

I have funny result when try to displaying below html file. The browser like Firefox, Safari and IE (so far that I have tested) give me wrong result. Be careful when use <htmlElement /> when you need to define empty element, it is safer when you do it with <htmlElement></htmlElement>. Your browser may interpret differently :D
This is my simple html file.

<table>
    <tr><td>
        <div id="table1">
            <table border="1" summary="This table should be empty"/>here some text
        </div>
    </td></tr>
    <tr><td>Some text</td></tr>
    <tr><td>
        <div id="table2">
            <table border="1" summary="This is correct"></table>
            <p>here some text</p>
        </div>
    </td></tr>
    <tr><td>Some text2</td></tr>
    <tr><td>
        <div id="table1">
            <table border="1" summary="This is correct because this table is empty"/>here some text
        </div>
    </td></tr>
</table>

Output captured from firebug-Firefox extension

<div id="table1">here some text
     <table border="1" summary="This table should be empty">
       <tbody>
          <tr><td>Some text</td></tr>
          <tr><td>
                 <div id="table2">
              <table border="1" summary="This is correct"/>here some text
                 </div>
          </td></tr>
          <tr><td><Some text2</td></tr>
          <tr><td>
                 <div id="table1">here some text
                      <table border="1" summary="This is correct because this table is empty"></table>
                 </div>
          </td></tr>
       </tbody>
     </table>
</div>

Permanent link to this article: http://lindaocta.com/?p=16

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>