How to add a CSS stylesheet?

CSS stylesheet are included in the header using the css_link function.

     ~uri:(make_uri (Eliom_service.static_dir ())

This function has 2 parameters: the file path and unit.

The file path is generated using the make_uri function. This function creates the relative URL string using the static directory configured in the configuration file and the given list.


Insert this piece of code on the list given in parameter to the head function:

     (head (title (pcdata "Page Title"))
        [css_link ~uri:(make_uri (Eliom_service.static_dir ())
	        	  ["css";"style.css"]) ()])
     (body [p [pcdata "Hello World!"]]))))

Or you can use: Eliom_tools module

◄ How does a page's source code look?

Download full code


◄ Back to the Quick Howto's