Home  >  Q&A  >  body text

Why are the resulting (after running the html/css code) box sizes of the div and label different when applying the same set of properties?

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 was expecting the same size box but found a different one.

P粉788571316P粉788571316374 days ago364

reply all(1)I'll reply

  • P粉066224086

    P粉0662240862023-09-13 17:37:56

    Just add display: block; to your CSS.

    like this:

    div, a {
        display: block;
        height: 100px;
        width: 200px;
        border: 5px solid black;
        margin: 15px;
    }
    

    reply
    0
  • Cancelreply