'Line break when combining image_tag and text in Rails navbar

I want to combine a logo and the brandname as text in my bootstrap based navbar. The problem is I can't figure out why there is a line break and the text not on the same line as the logo. Can anyone assist?

<%= link_to image_tag("brand_logo.png") + " Brandname", root_path, class: "navbar-brand" %>

I tried to add "display: inline;" in my CSS-file but this doesn't help. Please see the screenshot for the browser inspect

Thank you.



Solution 1:[1]

You need to give the property display:inline to the image_tag itself.

<%= link_to root_path, class: 'navbar-brand' do %>
  <%= image_tag('brand_logo.png', style: 'display:inline') %>
  <%= 'Brandname' %> 
<% end %>

Solution 2:[2]

Thanks coorasse

 <div class="container-fluid">
    <%= link_to root_path do %>
      <%= image_tag 'image.svg', alt:'', class:'', style:'display:inline' %>
      <span class="" >TEXT LINK</span>
    <% end %>
</div>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 coorasse
Solution 2 coopeu