How to add a CSS stylesheet?

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

css_link
     ~uri:(make_uri (Eliom_service.static_dir ())
              ["css";"style.css"])
     ()

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.

Where?

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

(html
     (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

Links

◄ Back to the Quick Howto's