![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is wrapping a div inside an anchor tag valid code?
Yes, according to HTML5 Specifications, we can place a div inside an anchor tag, for example −
<a href="#" target="_blank"> <div class="demo"></div> </a>
Another example −
<a href= www.tutorialspoint.com> <div> this now becomes a link </div> </a>
The HTML5 allows <a> tag to be wrapped around a <div> element. Therefore, the <div> will be visible inside the <anchor> tag.
Example
Let us see an example for div inside the <anchor> tag −
<!DOCTYPE html> <html> <head> <style> .container { position: relative; background-color: orange; width: 200px; height: 200px; } .container a { position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 999; } </style> </head> <body> <h1>Demo Heading</h1> <div class="container"> <div class="div__one"> div one </div> <div class="div__two"> div two </div> <a href="https://tutorialspoint.com"></a> </div> </body> </html>
Output
![](https://www.tutorialspoint.com/assets/questions/media/495676-1670229901.png)
Click on the orange colored div and the link will open −
![](https://www.tutorialspoint.com/assets/questions/media/495676-1670229917.png)
Advertisements