-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?

Visal
  • 199
  • 2
  • 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,248
  • 3
  • 12
  • 38
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,169
  • 6
  • 14