HTML5 Place block-level element sample code inside a tag

Source: Internet
Author: User

In contrast to XHTML, HTML5 a series of reflections through simpler elements, and frankly, this is really a much-needed simplification. One of these simplifications is the ability to wrap the block-level elements like div,h tags (h1...h6), and paragraph mark p through <a> labels. You're right: use a tag to wrap block-level elements (translator Note: Before HTML5, a label belongs to the inline element, and Div,h1,p is a block-level element, and if forced, it may be forcibly truncated to multiple a tags.) Of course, it's all about browsers. ).

Sample code:

Copy Code code as follows:


&lt;body&gt;


&lt;a href= "/about-page.php" &gt;


&lt;div class= "article" &gt;


&lt;h1&gt; about David walsh&lt;/h1&gt;


&lt;p&gt;

The original author is a 27-year-old Web Developer and is an expert advisor on jquery & MooTools, Madison, Wisconsin,
. It is also the founder and master of Wynq Web Labs. Motto: "I don't design websites, just let them run."


&lt;/p&gt;


&lt;/div&gt;


&lt;/a&gt;


&lt;/body&gt;


that is, a label for a is wrapped around an element like div,p,h1, and it should be noted that you cannot include another a tag within a label, otherwise what happens is likely to be inconsistent across browsers.

What do you think of it? The
is contradictory to the inclusion of a block-level element with a label, and it feels like a bunch of junk code when you view it quickly. On the other hand, to avoid this, we always use JavaScript to handle it. Clickable elements are designed to accomplish tasks and functions, and using native HTML to do this is more natural than JS, and is sometimes certainly convenient. What I want to ask is: What do you think of this practice? Can you use it immediately? Please share your views!
(translator: In the translator's project, a team member uses this function.) It's hard to look inside the myeclipse because it's a bunch of yellow warnings. But objectively, sometimes some code works really well, like something <red>.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.