开发者

For HTML and CSS, if styling a table of product info using table, why not style one row also using a table?

I think the conventional prac开发者_StackOverflow中文版tice is to style a table of products, each row having

photo        name        rating  
photo        name        rating  
  [...]

using a <table> element. That's for the products page. But what about for the productpage (a single product), when it is just

rating      name     photo

across the screen near the top, it is one row of the table in the first situation too, so shouldn't using table be a good practice? Because the conventional thinking is that, in a situation like this, it is more of a layout, so using CSS with floated divs instead. Can this situation really can go either way or really one way is better than the other?


Table:

<table>
    <tr>
        <td> <span>Rating</span> </td>
        <td> Name </td>
        <td> <img src="..."> </td>
    </tr>
</table>

DIV + CSS:

<div>
    <span>Rating</span> Name <img src="...">
</div>

I'd go with the DIV/CSS solution.

Live demo: http://jsfiddle.net/simevidas/2tXZ6/2/


It's tabular data. You can use a table, even if its one row. Semantically correct to me. As far as what's simpler, some say using tables for layout is simpler. Is it correct? Not to me. (...and here comes the HTML/CSS vs. Table layout firestorm!)

If you're laying out products, chances are that its being pulled from a database. Which means it will probably be populating a data table anyway. Use CSS to position and 'decorate' your gridview. That's much easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜