Skip to content

Hiccup style syntax for generating HTMLλ︎

Rather that write HTML code, you can use Clojure to write it for you. This provides a simpler to type syntax based on the vector in Clojure.

Instead of angle bracket < > and tags like p. you can define section using vectors [ ] and :keywords.


So for a header you would write

[:h1 "I am a header"]]

A simple piece of HTML (for web pages)

  [:h1 "This is HTML code generated by Clojure"]
  [:p "Hiccup is a simple way to write HTML in Clojure, without all those angle brackets"]
  [:a {:href ""}
  "Read more about Hiccup at its Github repository"]]

We can also create HTML for displaying images

 {:src ""}]