Quantcast
Channel: Is putting a div inside an anchor ever correct? - Stack Overflow
Browsing latest articles
Browse All 17 View Live
↧

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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article


Answer by Jon Hadley for Is putting a div inside an anchor ever correct?

It's wrong. Use a span.

View Article

Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article


Answer 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 Article

Is 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

Browsing latest articles
Browse All 17 View Live




<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>