Natural Docs allows you to create your own CSS style for the generated HTML, or you can just make adjustments to the default one.  There's two ways to do it depending on how much you want to change: a simple style, where you're just adding a single CSS file on top of the default, or an advanced style, where you can include multiple images, CSS, and JavaScript files.

In both cases you apply the style to your project by using the Style property in Project.txt or the -s command line option.

Simple Styles

A simple style is just a single CSS file in your project configuration folder.  If you create the file Red.css, you use the name "Red" in Project.txt or on the command line to apply it.  Your documentation will have the default style applied and then your file added to override any settings you want.

This makes it very easy to make small changes.  If you only want to add colors to prototypes or change the syntax highlighting this is the fastest way to do it.  If you want to do a more elaborate redesign of the appearance you may want to use an advanced style instead.

Advanced Styles

An advanced style is a subfolder in your project configuration folder that contains a Style.txt file.  If you have a subfolder Red that contains Style.txt, you would use the name "Red" in Project.txt or on the command line to apply it.

Creating a New Style

To get started, create the subfolder in your project configuration folder and leave it empty.  Change Project.txt or the command line to use the folder name as the name of the style and run Natural Docs.  It will create a starter Style.txt in that folder for you.

The style will be set to inherit Default, which means anything you add will be on top of the default style with all its CSS and images.  If you'd like to start from scratch visually, change the Inherit line to use DefaultJS instead.  This provides only the JavaScript that makes the documentation function but none of the visual formatting.

Adding Content

Put the files you want to use in the subfolder you created for your style.  Any CSS, JavaScript, JSON, images, and web font files in there will be automatically copied to the output folder.  The folder hierarchy is preserved, so if you have an images subfolder and your CSS file is in the style's root folder you can reference them with url("images/mypicture.jpg").  If you inherit from Default and want to reference its resources you can use url("../Default/images/search.png").

CSS and JavaScript are not automatically linked to the HTML files though.  You have to add them with Link lines in Style.txt like "Link: MyStyle.css".  If you want to have some JavaScript execute automatically you can also add an OnLoad handler with "OnLoad: MyFunction();".

You can choose to limit both Link and OnLoad to just frame or content pages.  The frame page manages the header, footer, file and class menus, and the summary.  The content is the file or class documentation displayed in the rightmost panel, which is an iframe.  If your JavaScript only applies to the content files you can use "Content OnLoad" instead of "OnLoad" which would apply to both.

Prototype Colors

Natural Docs has different prototype background colors for each type: functions are gray, properties are blue, variables are yellow, etc.  However, if you create your own comment types and then include prototypes for them, they default to black and white.  You can use these settings to give color to your custom prototypes.

The CSS class you need is T plus the name of your comment type using only A-Z.  Numbers, spaces, and symbols are stripped out, so if your custom comment type is called Sound Effect its CSS class would be TSoundEffect.  If removing these characters doesn't give a good result you can also manually set the Simple Identifier property in Comments.txt and add a T to that.

.TSoundEffect .NDPrototype,
.TSoundEffect .SuEntryIcon,
.TSoundEffect .SeEntryIcon {
background-color: #F0F0F0;
border: 1px solid #C7C7C7;

NDPrototype is for prototypes appearing in the page content, whereas SuEntryIcon and SeEntryIcon are for the color swatches that appear in the summary and search results respectively.

Syntax Highlighting

If you'd like to use your own syntax highlighting style instead of the one Natural Docs provides, set the fonts and colors on these CSS classes:

.SHCommentComments such as // Text
.SHKeywordKeywords such as int
.SHNumberNumeric literals such as 12
.SHStringString literals such as "Text"
.SHPreprocessingDirectivePreprocessing directives such as #ifdef
.SHMetadataMetadata such as C#'s or Python's

So for example if you wanted comments to be green and in italics, you would include this in your CSS:

.SHComment {
color: #008000;
font-style: italic;
CSS Structure

The complete CSS structure of the output is documented here.

Inherit: [style]

Inherit the settings of another style.  All of its settings will be applied before yours.  You can add this line multiple times to inherit more than one.

If you just want to make some changes to the default style, inherit Default.  If you're building your own page design from scratch but want to keep the default JavaScript functions, inherit DefaultJS.  This will include the code but not the CSS or images.

Link: [file]
Frame Link: [file]
Content Link: [file]

Links a .css, .js, or .json file to the generated HTML pages via link or script tags.  You can link it to just the frame page, which handles the header, footer, menu, and summary, or to content pages, which is the documentation in the rightmost panel.  If you do not specify a page type, it will be linked to every page.

While all files in your style folder will be copied to the output folder automatically, they are not linked automatically.  Since JavaScript files can be loaded dynamically and CSS files can be imported from other ones, you must explicitly link the ones you want.

OnLoad: [statement]
Frame OnLoad: [statement]
Content OnLoad: [statement]

Adds a JavaScript statement to the page's OnLoad handler.  You can add it to just the frame page, which handles the header, footer, menu, and summary, or to content pages, which is the documentation in the rightmost panel.  If you do not specify a page type, it will be added to every page.

The OnLoad statement is limited to a single line.  If you have a lot of code it's recommended that you make it a function in a separate .js file, link that file, and then call the function from this statement rather than trying to cram it all on this line.