Table of Contents

css

using css… bla bla bla

Using IDs

When you use custom IDs in your template for assigning styles, be sure that the ID does not conflict with an existing ID. In particular, be sure that it won’t conflict with the IDs automatically assigned to section headers. The easiest way to ensure this is to use two adjacent underscores (__) in your ID. Because section IDs are always valid pagenames, they will never contain adjacent underscores.

In plugins use <pluginname>__<id>. For example 'searchindexplugin__buttonfield'

Styling based on page properties

Most often people only need to modify a style of some element on all pages. For example one may want to change the font style for h1 heading. But from time to time, it is desirable to modify a style only on certain page. You could want a special background for any page in the attic namespace so that readers instantly realize that they are reading outdated documentation left as a reference. One could also want to add a specific style to some elements if visitor is a connected user, or only on edit page but not when viewing the page. This is possible because most template use an internal DokuWiki function called tpl_classes(). All you need to know is that this function is used by templates to add classes based on page properties to one of the top div element. For example, when a connected visitor is reading the page :wiki:syntax the default template produces this div element :

<div id="dokuwiki__top" class="site dokuwiki mode_show tpl_dokuwiki loggedIn   showSidebar hasSidebar lv_1 ns__wiki ns_wiki_ pg_syntax pg_wiki_syntax">

This offers quite a lot of possibilities. you can create a style for

If your particular template does not use the tpl_classes() function, you will have different classes available. In fhis case, you may want to contact the developer of your theme and ask that the template makes use of this function.

Enough examples, here are the details :

example selectors

To target all start page in any namespace use this

div.dokuwiki.pg_start

To target the main page

div.dokuwiki.home

To target a page exactly in the fr namespace

div.dokuwiki.ns__fr.lv_1

To target a page anywhere in the fr namespace (meaning fr:syntax or fr:plugin:struct:aggregation)

div.dokuwiki.ns__fr

To target “this page does not yet exist” in any namespace when using the boozurk template and only for anonymous user and when user is viewing the page but not editing it

div:not(.loggedIn).dokuwiki.notFound.mode_show.tpl_boozurk

A note for non english page and namespace

CSS accepts fnencode settings