html块级元素和行级元素
HTML5 presents a simpler line of thought with HTML than XHTML. And quite honestly, it's a much needed simplification. One of those simplifications is the ability to wrap block-level elements like DIV
s, H-tags, and P
's with basic A
elements. You read that correctly: wrap block-level elements with A
tags.
与XHTML相比,HTML5提出了更简单HTML思路。 老实说,这是非常需要的简化。 这些简化之一是能够用基本的A
元素包装块级元素(如DIV
,H-tags和P
)。 您没有看错:用A
标签包装块级元素。
HTML5代码 (HTML5 Code)
<body>
<a href="/about-page.php">
<div class="article">
<h1>About David Walsh</h1>
<p>
I'm a 27 year old Web Developer and jQuery & MooTools Consultant working from Madison, Wisconsin. I am Founder and Lead Developer for Wynq Web Labs. I don't design the websites, I just make them work.
</p>
</div>
</a>
</body>
There you have it. A simple A element wrapping DIV
s, H1
's, and P
's. Note that you may not wrap A
elements with larger A
elements.
你有它。 一个简单的A元素,用于包装DIV
, H1
和P
请注意,您不得将A
元素包装成较大的A
元素。
你怎么看? (What Do You Think?)
I have mixed feelings about wrapping block-level elements with A tags. Taking a quick look at the HTML makes me feel as though the code is dirty or wrong. On the flip side, we've been using JavaScript to skirt around doing this for a long time. My Clickables class aims to accomplish this task. Using HTML to make something clickable is more natural and doesn't require JavaScript. I guess my question is: how do you feel about this practice? Will you use it right away? Please share!
我对使用A标签包装块级元素有不同的感觉。 快速浏览HTML会使我感觉代码似乎是肮脏的或错误的。 另一方面,很长一段时间以来,我们一直在使用JavaScript绕过这一步。 我的Clickables类旨在完成此任务。 使用HTML来使某些内容可点击更自然,并且不需要JavaScript。 我想我的问题是:您对此做法有何看法? 您会立即使用它吗? 请分享!
html块级元素和行级元素