Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Child a tag width 100% to the parent width in this case not working

I am trying an a tag take all 100% width of the parent but anything works. I tried with div tag and p tag and it works, do not know if i am missing something with a tags

html

<div >
  <a href="">dsa</a>
</div>

css

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

div {
   background: red;
   width: 500px;
   height: 20px;
}

div a {

  width: 100%;
  border: 4px solid black;
}

Codepen

>Solution :

Change display: inline-block for a tag.

div {
  background: red;
  width: 500px;
  height: 20px;
}

div a {
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  line-height: 100%;
  border: 4px solid black;
}
<div>
  <a href="">dsa</a>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading