I have used the following piece of code where I have used div tag inside anchor tag. The code is working fine but I am not sure if this is the correct format. Is it correct to use div inside anchor tag ?
<a class="discount-popup" href="#" id="WC_Link_ProductDiscount_1_<c:out value="${discountCounter.count}"/>">
<div id="view_offer" style="display: block;">
<u style="color: #000000;"><c:out value="View offer details" escapeXml="true" /></u>
</div>
<div id="offer_details" style="display: none;">
<c:out value="${calculationCodeDBs[0].longDescriptionString}" escapeXml="false" />
</div>
</a>
In HTML5 you can. In previous versions of HTML you can't. To make this code valid you need to set the correct doctype:
<!DOCTYPE html>
With this doctype the browser identifies HTML5 page. Put it before <html> tag.
Yes, its fine to you use DIV elements inside an anchor tag, but you will need to setup your CSS correctly for each one (height, width, display, etc), otherwise, the height will revert to the line height by default.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With