CSS Guide

It’s important to understand the internal HTML file structure and styles in order to design your own CSS style for Natural Docs.  If you’re content with the default styles, there’s no need to read this document.

The diagrams are designed for clarity.  In the actual HTML, you’d obviously see “<pre class=CCode></pre>” instead of “<pre CCode></pre CCode>”.  If there’s no element in the diagram tag, for example “<CTitle></CTitle>”, that means you shouldn’t rely on what HTML element it is.  Just refer to them as .Style in your CSS file instead of Element.Style.

Summary
It’s important to understand the internal HTML file structure and styles in order to design your own CSS style for Natural Docs.
The body tag is used to distinguish between the types of pages.
Natural Docs pages include JavaScript to detect which browser the user is running and apply styles so that you can work around browser quirks right in the CSS file.
All the content of a given file is either contained in a ContentSection or a FramedContentPage.
Everything is enclosed in a MenuSection or a FramedMenuPage.
Everything is contained in a single ClassHierarchy.
Everything is enclosed in a single Summary.
All links to symbols have a type style prefixed with L.
Everything is enclosed in a IndexSection or an FramedIndexPage.
hidden.
How the page structure has changed throughout the various releases.

Page Structure

The body tag is used to distinguish between the types of pages.  For framed pages, its style will be FramedMenuPage, FramedContentPage, or FramedIndexPage depending on what it is.  Non-framed pages have a body style of UnframedPage.

On unframed pages, the menu will be contained in a MenuSection td and the content or index in ContentSection or IndexSection tds.  Tables are used instead of CSS positioning for better compatibility with older browsers and because they have the ability to stretch when its content is too wide and collapse when the browser window is too small.

Unframed Page

<body UnframedPage>
[browser styles]

    <table><tr>

        <td MenuSection>
            Menu
        </td MenuSection>

        <td ContentSection/IndexSection>
            Content or Index
        </td ContentSection/IndexSection>

    </tr></table>

    <Footer>
        Footer
    </Footer>

[/browser styles]
</body UnframedPage>

Framed Menu Page

<body FramedMenuPage>
[browser styles]

    Menu

    <Footer>
        Footer
    </Footer>

[/browser styles]
</body FramedMenuPage>

Framed Content/Index Page

<body FramedContentPage/FramedIndexPage>
[browser styles]

    Content or Index

[/browser styles]
</body FramedContentPage/FramedIndexPage>

Page Styles

UnframedPageAn unframed page.  Will be applied to a body tag.
FramedMenuPageA framed menu page.  Will be applied to a body tag.
FramedContentPageA framed content page.  Will be applied to a body tag.
FramedIndexPageA framed index page.  Will be applied to a body tag.
MenuSectionThe menu section in a non-framed page.  Will be applied to a td tag.
ContentSectionThe content section in a non-framed page.  Will be applied to a td tag.
IndexSectionThe index section in a non-framed page.  Will be applied to a td tag.
FooterThe page footer.  Will be in a framed menu page or on its own in a non-framed page.

Browser Styles

Natural Docs pages include JavaScript to detect which browser the user is running and apply styles so that you can work around browser quirks right in the CSS file.

Immediately after the body tag, the browser type and version styles will be applied.  However, neither are guaranteed to be there; the user may have JavaScript turned off or be using a browser that isn’t detected.  These styles should only be used to correct minor flaws and should not be heavily relied on.

<body>

    <browser type>?
        <browser version>?

            Page Content

        </browser version>?
    </browser type>?

</body>

For example, if a CTopic’s style is giving you problems in Internet Explorer 4, override it with .IE4 .CTopic.  If a MTitle’s style gives you a problem in Opera 5 but only in frames, override it with .FramedMenuPage .Opera5 .MTitle.

Browser Types

If the browser is not one of the types below, neither this nor the browser version will be present.  There’s the possibility that some obscure browser will appear as one of the others by spoofing, but the most prominent of these, Opera, Konquerer, and Safari, are taken care of.

IEInternet Explorer
GeckoThe Gecko rendering engine, which includes Mozilla, Netscape 6+, etc.
OperaOpera
KHTMLThe KHTML rendering engine, which includes Konqueror and Safari.
NetscapeThe pre-Gecko Netscape rendering engine, which is 4.x and earlier.

Browser Versions

If the browser is not one of the versions below, this style will not be present.  The browser type still may be.  Gecko and KHTML-based browsers are not broken out into sub-versions.

IE4Internet Explorer 4.x
IE5Internet Explorer 5.x.  Yes, 5.0 and 5.5 are grouped together, as are Mac and Windows versions.
IE6Internet Explorer 6.x.
Opera5Opera 5.x.
Opera6Opera 6.x.
Opera7Opera 7.x
Netscape4Netscape 4.x.

Content Structure

All the content of a given file is either contained in a ContentSection or a FramedContentPage.  All other content styles are prefixed with a C.

Each piece of content is a CTopic surrounded by its type; for example, CFunction for a function.  Inside that are the CTitle and if necessary, CBody.  Inside CBody are analogues to all the top-level NDMarkup tags: CHeading, CParagraph, etc.  Styles like CParagraph exist so that you only style explicit NDMarkup paragraphs, not any p that appears.

In addition to the top-level NDMarkup tags, you also have CPrototype, CTitle, and SummariesSummaries are described in their own section.

<Content>

    <CType (CFunction, CItem, etc.)>
        <CTopic>

            <CTitle>
                Topic title
            </CTitle>

            <CBody>

                <ClassHierarchy> (See it's section)

                <CPrototype>
                    Prototype
                </CPrototype>

                <p CParagraph>
                     Paragraph
                </p CParagraph>

                <CHeading>
                    Heading
                </CHeading>

                <pre CCode>
                Code
                </pre CCode>

                <ul CBulletList>
                    <li>
                    Bullet item
                    </li>
                </ul CBulletList>

                <table CDescriptionList>
                    <tr>
                        <td CDLEntry>
                        Entry
                        </td CDLEntry>
                        <td CDLDescription>
                        Description
                        </td CDLDescription>
                    </tr>
                </table CDescriptionList>

                <Summary> (See it's section)

           </CBody>

       </CTopic>
    </CType (CFunction, CItem, etc.)>

</Content>

Take advantange of the CSS inheritance model.  For example, you can style all titles via .CTitle, and you can style specific titles with .CType .CTitle.

Content Styles

CTopicAn individual topic.
CTitleThe title of a topic.
CBodyThe body of a topic.  May not exist.
CPrototypeA prototype.
CParagraphA paragraph.  Is implemented with a p.
CHeadingA heading.
CBulletListA bullet list.  Is implemented with a ul.
CCodeA section of code.  Is implemented with a pre.
CDescriptionListA description list, which is the type of list you’re reading right now.  Is implemented with a table.
CDLEntryA description list entry, which is the left side.
CDLDescriptionA description list description, which is the right side.
#MainTopicThe ID given to the main topic, which is the first in the file.  It is applied to the topic type tag, such as CClass and CFunction.
CClassA class topic.
CSectionA section topic.
CFileA file topic.
CGroupA group topic.
CFunctionA function topic.
CVariableA variable topic.
CConstantA constant topic.
CTypeA type topic.
CGenericA generic topic.
CClassListA class list topic.
CFileListA file list topic.
CFunctionListA function list topic.
CVariableListA variable list topic.
CConstantListA constant list topic.
CTypeListA type list topic.
CGenericListA generic list topic.

Menu Structure

Everything is enclosed in a MenuSection or a FramedMenuPage.  All other menu styles are prefixed with an M.

The title is an MTitle and will always be at the beginning of the menu if it exists.  If a subtitle exists as well, it will appear as an MSubTitle inside MTitle.  Subtitles aren’t allowed without titles.  Every other entry in the menu is contained in a MEntry, inside of which there’s the type, such as MFile and MGroup.  Inside of that is the content.  With MGroups, there’s also a section inside called MGroupContent which can contain more entries.  Here’s the diagram:

<Menu>

    <MTitle>
        Menu title

        <MSubTitle>
            Menu sub title
        </MSubTitle>

    </MTitle>

    <MEntry>
        <MFile>
            <a href>File</a href>
        </MFile>
    </MEntry>

    <MEntry>
        <MText>
            Text
        </MText>
    </MEntry>

    <MEntry>
        <MLink>
            <a href>Link</a href>
        </MLink>
    </MEntry>

    <MEntry>
        <MGroup>
            <a href>Group</a href>
            <MGroupContent>

                (MEntries)

            </MGroupContent>
       </MGroup>
    </MEntry>

</Menu>

The MFile entry that’s currently selected will have the #MSelected ID, so you can reference it in CSS via .Menu .MFile#MSelected.

Menu Styles

MTitleThe title of the menu.
MSubTitleThe subtitle of the menu.  Will appear within MTitle.
MEntryThe parent container of MFile and MGroup entries.
MFileA file entry.
MGroupA group entry.
MGroupContentA container for a MGroup’s content.
MTextA plain text entry.
MLinkAn external link entry.
#MSelectedThe ID of the currently selected MFile.

Class Hierarchy Structure

Everything is contained in a single ClassHierarchy.  Each entry is surrounded by its type, such as CHParent, and the generic CHEntry.  Depending on the context, entries may be surrounded by one or more CHIndents.

<ClassHierarchy>

    <CHIndent>?

        <type (CHParent, CHCurrent, etc.)>
            <CHEntry>

                Entry

            </CHEntry>
        </type (CHParent, CHCurrent, etc.)>

    </CHIndent>?

</ClassHierarchy>

Class Hierarchy Styles

ClassHierarchyThe topmost style containing everything.
CHEntryA generic class entry.
CHParentThe style for a parent class.
CHCurrentThe style for the current class, which is the one the hierarchy is generated for.
CHChildThe style for a child class.
CHIndentA style used to indent a level.

Summary Structure

Everything is enclosed in a single Summary.  All the other summary styles are prefixed with an S.

STitle holds the actual word “Summary” and SBorder and STable hold the content.  SBorder exists because different browsers apply table padding attributes in different ways.  STable exists as a class to separate the main table from any other tables that may be necessary.  Here’s a diagram:

<Summary>

    <STitle>
        Title
    </STitle>

    <SBorder>
        <table STable>
            ...
        </table STable>
    </SBorder>

</Summary>

On to the table content.  Rows may have the SMarked style, which means they should be tinted for easier readablity.

Since we many attributes left to apply, they’re done with a kludgy mess of styles within each cell.  It’s hacky and verbose, but it works and is compatible everywhere.  We apply the type, whether it’s an entry or a description, and if it’s in a group or class as shown below:

<tr SMarked?>
    <td SEntrySize?>

        <SType (SFunction, SClass, etc.)>
            <SEntry>
                <SInClass/Section>? <SInGroup>?

                    <a href>Entry</a href>

                 </SInGroup>? </SInClass/Section>?
            </SEntry>
        </SType>

    </td SEntrySize?>
    <td SDescriptionSize?>

        <SType (SFunction, SClass, etc.)>
            <SDescription>
                <SInClass/Section>? <SInGroup>?

                    Description

                </SInGroup>? </SInClass/Section>?
            </SDescription>
        </SType>

    </td SDescriptionSize?>
</tr SMarked?>

SInGroup, SInClass, and SInSection exist to allow indenting.  They’re there in their current arrangement (all three “there”s in one sentence :) because implementing it as nested tables, while structurally cleaner, won’t allow the desciptions to line up on the right throughout the entire summary.

Use the power of CSS’s inheritance rules to specify styles.  For example, to set the style of a group entry, apply it to .SGroup .SEntry.  However, you could also apply a style to both the group’s entry and description by applying the style to .SGroup.  Or, you could apply a style to all the entries by applying it to .SEntry.  And so on.

Summary Styles

SummaryThe topmost style containing the entire summary.
STitleContains the summary title, which is the part that actually says “Summary”.
SBorderSurrounds STable, since some browsers can’t do table padding right.  A hack, I know.
STableThe actual summary table.  This class separates it from other layout tables that may appear.
SMarkedA class applied to rows that should have a slightly different color than the rest of the rows to make them easier to read.
SEntrySizeA class applied to one entry cell to specify the column width.
SDescriptionSizeA class applied to one description cell to specify the column width.
SEntryThe entry (left) side of the table.
SDescriptionThe description (right) side of the table.
SInGroupSurrounding entries and descriptions that are part of a group.
SInClassSurrounding entries and descriptions that are part of a class.
SInSectionSurrounds entries and descriptions that are part of a section.
SMainThe main summary.
SClassFor class summaries.
SSectionFor section summaries.
SFileFor file summaries.
SGroupFor group summaries.
SFunctionFor function summaries.
SVariableFor item summaries.
SGenericFor generic summaries.
SClassListFor class list summaries.
SFileListFor file list summaries.
SFunctionListFor function list summaries.
SVariableListFor variable list summaries.
SGenericListFor generic list summaries.

Link Structure

All links to symbols have a type style prefixed with L.  The only exceptions are summary entries; summary descriptions use them as well.

<a LType (LFunction, LClass, etc.)>
    Link
</a LType (LFunction, LClass, etc.)>

You can use this to make links to different symbols appear in different styles.  For example, making .LClass bold will make all links to classes bold, except when appearing in summary entries.  You can combine this with other styles to be even more specific.  For example, you can apply a style to function links appearing in summary descriptions with .SDescription .LFunction.

Link Styles

LClassLink to a class.
LSectionLink to a section.
LFileLink to a file.
LGroupLink to a group.
LFunctionLink to a function.
LVariableLink to a item.
LGenericLink to a generic.
LClassListLink to a class list.
LFileListLink to a file list.
LFunctionListLink to a function list.
LVariableListLink to a variable list.
LGenericListLink to a generic list.
LURLLink to an external URL.
LEMailLink to an e-mail address.

Index Structure

Everything is enclosed in a IndexSection or an FramedIndexPage.  All other index styles are prefixed with an I.

<Index>

    <IPageTitle>
        Page Title
    </IPageTitle>

    <INavigationBar>
        A - <a href>B</a href> - C ...
    </INavigationBar>

    <ISection>

        <IHeading>
            Heading (A, B, etc.)
        </IHeading>

        <IEntry>
            <ISymbol>
                <a href>Symbol</a href>
            </ISymbol>,
            <IParent>
                Class
            </IParent>
        </IEntry>

        <IEntry>
            <ISymbol>
                Symbol
            </ISymbol>
            <ISubIndex>
                <IEntry>
                    <IParent>
                        <a href>Class</a href>
                    </IParent>
                </IEntry>
                ...
            </ISubIndex>
        </IEntry>

        <IEntry>
            <ISymbol>
                Symbol
            </ISymbol>
            <ISubIndex>
                <IEntry>
                    <IParent>
                        Class
                    </IParent>
                    <ISubIndex>
                        <IEntry>
                            <IFile>
                                <a href>File</a href>
                            </IFile>
                        </IEntry>
                        ...
                    </ISubIndex>
                </IEntry>
                ...
            </ISubIndex>
        </IEntry>

    </ISection>

</Index>

Every index entry is an IEntry followed by a type.  If there’s only one class and definition file for a symbol, it gets the link.  However, if there’s more of either, they get broken out into ISubIndex entries.  A IParent subindex can be broken out yet again into an IFile subindex.

It’s called IParent instead of <IClass> because class entries are ISymbolsIParents are only used when the symbol has a class.  If the symbol is a class, the symbol is global.

Index Styles

IndexSurrounds the entire index.
IPageTitleThe page title.
INavigationBarThe navigation bar.
ISectionA section of entries.
IHeadingA heading for a section of entries.
IEntryAn entry in the index.
ISymbolThe entry symbol.
IParentThe entry parent class.  If the entry is a class, this isn’t defined because classes are global and don’t have parent classes.  This is why it’s called IParent instead of IClass; hopefully it’s less confusing.
IFileThe file the entry is defined in.
ISubIndexSurrounds all IEntry’s in a sub-index.

Tool Tip Structure

Tool tips may appear anywhere in the page, mainly because it’s assumed that they will use position: absolute and visibility

hidden.

The entire tool tip is found in a CToolTip style, with a CType style inside it.  CTypes are normally outside their elements, but that would cause it to be partially visible in this case.  We need CToolTip to be the outermost style so its visibility and position can be manipulated in JavaScript.

Inside there’s a CPrototype and/or the description text.  The description text has no special surrounding tags.

<CToolTip>

    <CPrototype>
        Prototype
    </CPrototype>

    Summary text

</CToolTip>

Tool Tip Styles

CToolTipSurrounds the entire tool tip.  This must have position: absolute and visibility: hidden for the tool tip mechanism to work.

See also CPrototype.

Miscellaneous Styles

HBHidden Break.  Will surround a single space to try to break a word transparently.  Should be set to as small as possible.

Revisions

How the page structure has changed throughout the various releases.

1.2

1.16

  • Changed the first topic from having a CMain type to having a normal type with a #MainTopic ID.

1.1

1.0

  • The type tags now appear arround the CTopic tags instead of vice versa.
  • Added a CBody tag to surround non-CTitle elements.
  • SMarked now appears in tr’s instead of td’s, where it belonged in the first place.

0.95

0.91

  • Added LURL and LEMail link styles, since 0.91 added URL and e-mail links.
  • Added ISection style, which is better than IHeading floating on its own.

0.9

The content section in a non-framed page.
A framed content page.
The menu section in a non-framed page.
A framed menu page.
The topmost style containing everything.
The topmost style containing the entire summary.
The index section in a non-framed page.
A framed index page.
An unframed page.
An individual topic.
The title of the menu.
A function topic.
The title of a topic.
The body of a topic.
A markup format used by the parser, both internally and in NaturalDocs::Parser::ParsedTopic objects.
A heading.
A paragraph.
A prototype.
A class topic.
The subtitle of the menu.
The parent container of MFile and MGroup entries.
A file entry.
A group entry.
A container for a MGroup’s content.
The ID of the currently selected MFile.
The style for a parent class.
A generic class entry.
A style used to indent a level.
Contains the summary title, which is the part that actually says “Summary”.
Surrounds STable, since some browsers can’t do table padding right.
The actual summary table.
A class applied to rows that should have a slightly different color than the rest of the rows to make them easier to read.
Surrounding entries and descriptions that are part of a group.
Surrounding entries and descriptions that are part of a class.
Surrounds entries and descriptions that are part of a section.
An entry in the index.
Surrounds all IEntry’s in a sub-index.
The entry parent class.
The file the entry is defined in.
The entry symbol.
Surrounds the entire tool tip.
The ID given to the main topic, which is the first in the file.
Hidden Break.
A constant topic.
A constant list topic.
A type topic.
A type list topic.
Natural Docs pages include JavaScript to detect which browser the user is running and apply styles so that you can work around browser quirks right in the CSS file.
The body tag is used to distinguish between the types of pages.
Link to an external URL.
Link to an e-mail address.
A section of entries.
A heading for a section of entries.