什么是最好的HTML布局技术? DIV与表格 [英] What is the best HTML layout technique? DIVs vs Tables

查看:617
本文介绍了什么是最好的HTML布局技术? DIV与表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现使用表格作为主干更容易操作,特别是在垂直对齐时。但我似乎只是在使用带有大量CSS的DIV时找到代码示例,这些代码看起来像是CSS的内部工作方式。

I find using tables as the backbone easier to manipulate, specially when aligning things vertically. But I only seem to find code samples using DIV with heaps of CSS that looks like hacks into the inner workings of CSS.

推荐答案

使用< table> 进行布局被视为黑客攻击。

Using <table> for layout is considered a hack.

布局用于很久以前在CSS出现之前用< table> 来完成。如今,通常的做法是将项目的结构,样式和行为分别分为 HTML,CSS和JavaScript

Layouts used to be done with <table> a long time ago before CSS was around. Nowadays, it common practice to separate out the structure, styling, and behavior of your project into HTML, CSS, and JavaScript, respectively.

使用HTML5,推动使用语义标签,例如< article> < section> ,依此类推< div> 。尽管如此,< div> 仍然没问题,比< table> 优先100%,除非你专门工作使用表格数据。即使这样,实际的布局样式仍应在CSS中进行。

With HTML5, there has been a push for using semantic tags such as <article>, <section>, and so on in place of <div>. Nonetheless, <div> is still fine and 100% preferable over <table> unless you're specifically working with tabular data. Even then, the actual layout styling should still take place in your CSS.

这篇关于什么是最好的HTML布局技术? DIV与表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆