I am trying to create a header for my website and I want to place clickable social media logos that can redirect the user to that link. I am pretty new to frontend so from what I understand I have to place an anchor tag around the image element for it to be a clickable link. However placing the tag changes the dimensions of the element itself.
This works fine: [image is in the center with dims 25×25]
<img
className='invert float-left'
src='/static/github.svg'
height="25"
width="25"
alt="github logo"
/>
However, this does not: [anchor element tag has dims 25×40 and thus offsets the image upwards]
<a href="<URL>">
<img
className='invert'
src='/static/github.svg'
height="25"
width="25"
alt="github logo"
/>
</a>
2
Answers
You should insert
display: inline-flex;
on the<a>
tag.You can use this code, change the image or link as needed.