-1

I want to make a button with an image and some writing but it keeps in aligning it to the bottom or to the top. Below is my code:

<button><img src="https://www.google.com/s2/favicons?domain=google.com">&nbsp;Google</button>

 Google

Can you please help?

isherwood
  • 58,414
  • 16
  • 114
  • 157
Visal
  • 397
  • 1
  • 3
  • 10

2 Answers2

1

By using flexbox, you can achieve this easily.

button {
  display: inline-flex;
  align-items: center;
}

img {
  width: 40px;
}
<button><img src="https://www.designbust.com/download/1016/png/google_logo_png_transparent512.png">&nbsp;Google</button>
Abin Thaha
  • 4,493
  • 3
  • 13
  • 41
0

@Abin Thaha already posted, may be you were faster :)

<button style="display: inline-flex;align-items: center;"><img style="vertical-align: middle" src="https://www.google.com/s2/favicons?domain=google.com">&nbsp;Google</button>
Bharat
  • 1,192
  • 7
  • 14