开发者

Why are div:s preferred in website design?

I have search for the topic mentioned above but I didn't find good satisfying answer. What are the benefits of using divs only in html page ?开发者_Python百科 What else should be taken care while designing a web page ? Please help... Thanks


They aren't. Div is just a generic element that gets used when no appropriate semantic markup is available.

The most appropriately semantic markup combined with CSS is preferred.

This separates concerns and increases device independence and reusability of content.

By applying different (or no CSS), the same content will "Just work" on mobile, desktop, aural, print and so on.


Have a look this: http://webdesign.about.com/od/htmltags/qt/tipdivtag.htm


Divs are useful when you want to style elements and might want to move them around independently.

Designers used to use tables to layout pages, before the days of CSS, as a way to position major page elements. Now you can use divs and CSS to do the same thing and have a lot more flexibility.

To see what you can do with divs, check out http://www.csszengarden.com/.

Tables still make sense when you've got tabular data, and tables are styleable with CSS. For example gmail uses tables for emails when looking at an inbox.

You probably already know this, but to see what people are using you can inspect some pages. In Chrome right click on something and choose 'inspect element'. You can see the elements, their structure and the styles. There is something similar in recent versions of all the major browsers.


I think that it is best to use divs and tables together. Don't use either with out consideration, just because people say that it's the correct thing to do. Rather think about why or how you are going to use it and what it is going to contain. Everything should be there for a reason, otherwise it's just cluttering up the code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜