0

Right now I have a logo and then a link to the homepage. I want to combine them so that someone can click the logo and be directed to the homepage. I can't figure out how to do this with Hiccup.

    [:div.navbar-brand
         [:img {:src "/img/logo.png"
                :width 70
                :height 50}]
         
         [:a.navbar-item
          {:href "/"
           :style {:font-weight "bold"}}
          "Home"]

I am trying to do something like

    [:a.navbar-item
          {:href "/"}
           {:img {:src "/img/logo.png"
                  :width 70
                  :height 50}}]

But it's not working. What do I do?

JohnBradens
  • 119
  • 8
  • 1
    In 2nd example, does changing the { } enclosures to [ ] work for img?Changing `{:img {:src "/img/logo.png" :width 70 :height 50}}]` to `[:img {:src "/img/logo.png" :width 70 :height 50}]]` – Siege Dec 19 '21 at 20:44

1 Answers1

3

Img is element inside a, not attribute of a, so use square brackets:

[:a.navbar-item
           {:href "/"}
           [:img {:src "/img/logo.png"
                  :width 70
                  :height 50}]]
Martin Půda
  • 7,353
  • 2
  • 6
  • 13