html块级元素和行级元素_HTML5:用A来包装块级元素

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 DIVs, 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 DIVs, H1's, and P's.  Note that you may not wrap A elements with larger A elements.

你有它。 一个简单的A元素,用于包装DIVH1P 请注意,您不得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。 我想我的问题是:您对此做法有何看法? 您会立即使用它吗? 请分享!

翻译自: https://davidwalsh.name/html5-elements-links

html块级元素和行级元素

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值