↧
Answer by dkellner for Is putting a div inside an anchor ever correct?
Anything works ... until you nest them.You can stuff in tables and divs and birds and bees, and the browser will patiently play along. But as soon as you put another <a> tag inside, it will break...
View ArticleAnswer by KienHT for Is putting a div inside an anchor ever correct?
Update in Sep, 2023: latest HTML5 versionNothing is wrong with placing a div inside a tag. In fact, you can place just about anything inside a tag as long as they are categorized as transparent, except...
View ArticleAnswer by AkshayKumar for Is putting a div inside an anchor ever correct?
you can achieve this by adding "::before" Pseudo-elementPure CSS Trick ;)a:before{ position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; pointer-events: auto; content: "";...
View ArticleAnswer by Eugen for Is putting a div inside an anchor ever correct?
If you want to avoid the semantic trouble of placing divs inside anchor tags, just place the anchor tag on the same level as the divs, wrap them all with a container with position: relative, make your...
View ArticleAnswer by Beepye for Is putting a div inside an anchor ever correct?
Block level elements like <div> can be wrapped by <a> tags in HTML5. Although a <div> is considered to be a container/wrapper for flow content and <a>'s are considered flow...
View ArticleAnswer by Abir for Is putting a div inside an anchor ever correct?
With HTML5 specification... It is now possible to put a block-level element inside of an inline element. So now it's perfectly appropriate to put a 'div' or 'h1' inside of an 'a' element.
View ArticleAnswer by solveig for Is putting a div inside an anchor ever correct?
Just as an FYI.If your goal is to make your div clickable you can use jQuery / Java Script.Define your div like so:<div class="clickableDiv" style="cursor:pointer"> This is my div. Try clicking...
View ArticleAnswer by user1081070 for Is putting a div inside an anchor ever correct?
I think that most of the time when people ask this question, they have build a site with only divs, and now one of the div needs to be a link.I seen someone use a transparent empty image, PNG, inside...
View ArticleAnswer by Carl Smotricz for Is putting a div inside an anchor ever correct?
There's a DTD for HTML 4 at http://www.w3.org/TR/REC-html40/sgml/dtd.html . This DTD is the machine-processable form of the spec, with the limitation that a DTD governs XML and HTML 4, especially the...
View ArticleAnswer by Jon Hadley for Is putting a div inside an anchor ever correct?
It's wrong. Use a span.
View ArticleAnswer by NickFitz for Is putting a div inside an anchor ever correct?
Depending on the version of HTML you're catering to:HTML 5 states that the <a> element "may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as...
View ArticleAnswer by Greg for Is putting a div inside an anchor ever correct?
You can't put <div> inside <a> - it's not valid (X)HTML.Even though you style a span with display: block you still can't put block-level elements inside it: the (X)HTML still has to obey...
View ArticleAnswer by Chris for Is putting a div inside an anchor ever correct?
If you change it to a block-style element, then no, it's no longer 'wrong', but it probably won't validate. But it doesn't make much sense to do what you're doing. You should either just keep the...
View ArticleAnswer by Eloff for Is putting a div inside an anchor ever correct?
No it won't validate, but yes it generally will work in modern browsers. That being said, use a span inside your anchor, and set display: block on it as well, that will definitely work everywhere, and...
View ArticleAnswer by Ewan Todd for Is putting a div inside an anchor ever correct?
The W3C doc doesn't use concepts like wrong and sin, but it does use those like provide the means, may be appropriate and discouraged.Actually, in the second paragraph of section 4, the 4.01 spec...
View ArticleAnswer by Dave for Is putting a div inside an anchor ever correct?
If you're going to go to the effort of making <a> block, why not put <a> inside the div, being a block element it'll give you the same effect.
View ArticleIs putting a div inside an anchor ever correct?
I've heard that putting a block element inside a inline element is a HTML sin:<a href="http://example.com"><div> What we have here is a problem. You see, an anchor element is an inline...
View Article
More Pages to Explore .....