Can I include CSS file to Markdown -> HTML export?

I have a Markdown files in my Scrivener project. If I compile my file to HTML using MultiMarkdown -> Web page it does not define any CSS.

Is there any way to define that Scrivener would add to output HTML files? Or any ways to at least define some CSS what would be included and embedded to output or should I every time manually open HTML file and add that CSS file manually? :confused:

Markdown passes raw HTML without change. So it is always possible to include your code.

The problem in your case though is that the code wants to be in the head. So you could include that line in a separate document at the very beginning of your draft as the first file compiled. Then you would have to open the resulting HTML file that Scrivener compiles, and move that line up into the head.

With the Markdown to LaTeX compile options, Scrivener will invoke a specific perl script that contains all the translations, and this file can be customized by the operator. I don’t know whether such customization would be possible with the straight Markdown to HTML, which is a more basic option. Fletcher Penney’s MultiMarkdown site would be the best place to learn that, and Fletcher has an active Google Group with tips from experts where such a solution might be found.


MultiMarkdown has two different ways in which this can be done. If you just have one .css file to link up to your output, then in the Meta-Data compile option pane, create a field called “CSS”, and then in the content area below, paste the full URI to the .css file. As with standard HTML convention, this can be to a file:// local copy, or straight out to the Web.

If you have more complex needs, you can inject code directly into the HTML head element, using the “XHTML Header” meta-data field. Now you can copy and paste your custom header material into this field. Be careful with carriage returns, you should avoid using them in a meta-data field. Linearise the code block if you can. With that method, you can even specify your own block, or include multiple CSS and Javascript files—whatever you can do in a header.

This is all intermediate MMD usage by the way, nothing to do with Scrivener in particular.


Thank you very much! I added just index.css to metadata fields. Excellent, thanks!

I noticed now that CSS include is part of Multimarkdown features. Somehow when I compile Multimarkdown files, my metadata is in


I mean, my MD file is like this:

Title: Peliarvostelu: Tomb Raider
Author: Aleksi Räsänen
CSS: index.css

# Peliarvostelu: Tomb Raider

When I compile it with Scrivener, my metadata is between

tags, it is not stripped away from document (double checked that there is no empty line and space in the beginning of the document.

What could cause that?

Do you have it typed into the editor in Scrivener then? If so you need to put it in a special document called “Meta-Data”, which should be at the very top of your Draft folder. If the first document to be compiled has this name, then Scrivener will ensure that it is grouped together with any meta-data coming from the Meta-Data compile option pane, rather than set apart from it, causing it to become visible as ordinary text.