0

div, a {
    height: 100px;
    width: 200px;
    border: 5px solid black;
    margin: 15px;
}
<div>This is a div tag</div>
<a href="https://www.google.co.in" target="_blank">Google</a>

I expected to get the same size of boxes but found different ones.

connexo
  • 53,704
  • 14
  • 91
  • 128
Jackle
  • 3
  • 2
  • 2
    divs are display block by default but anchors are display inline by default. Add **a{display:block}** so you can control the anchor – imvain2 Jun 07 '23 at 19:29
  • Inline elements like `a` don't accept `height` or `width`. – connexo Jun 07 '23 at 19:39

1 Answers1

0

Just add display: block; to your CSS.

Like this:

div, a {
    display: block;
    height: 100px;
    width: 200px;
    border: 5px solid black;
    margin: 15px;
}
M0nst3R
  • 5,186
  • 1
  • 23
  • 36
  • While this creates the expected result, it does not explain the problem. OP in my understanding is asking for an explanation rather than a solution. – connexo Jun 07 '23 at 19:40