Home > Web Front-end > H5 Tutorial > body text

HTML5 placement of block-level elements within a tag sample code_html5 tutorial tips

WBOY
Release: 2016-05-16 15:48:51
Original
2162 people have browsed it

Compared to XHTML, HTML5 provokes a series of thoughts through simpler elements. Frankly speaking, this is a much-needed simplification. One of these simplifications is the ability to wrap block-level elements like divs, h tags (h1...h6), and paragraph tags P through the tag. You read that right: Use an A tag to wrap a block-level element (Translator's Note: Before HTML5, the a tag was an inline element, while div, h1, p, etc. were block-level elements. If you wrap it forcibly, it may be forcibly truncated. Multiple a tags. Of course, it’s all about the browser).

Sample code:

Copy code
The code is as follows:




About David Walsh Wisconsin. Also the founder and chief engineer of Wynq Web Lab. Motto: "I don't design websites, I just make them run."







That’s it, an A tag wraps elements such as div, p, h1. It should be noted that you cannot use an A tag Contains another A tag, otherwise what happens may be inconsistent across browsers.


What do you think?
I'm conflicted about using A tags to contain block-level elements, it looks like a bunch of junk code at a quick glance. On the other hand, in order to avoid this approach, we have been using JavaScript to handle it. The purpose of clickable elements is to complete tasks and functions, and using native HTML to complete this function is more natural than JS, and it is definitely convenient sometimes. What I want to ask is: What do you think of this practice? Can you use it immediately? Please share your views! (Translator’s note: In the translator’s project, a team member used this function. It’s very sad to see it in MyEclipse because there are a lot of yellow warnings. But objectively speaking, sometimes some codes are indeed Very effective, like something like )
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template