Pages: 1
Author Topic: Customize Tag on View by using CSS  (Read 2118 times)

Posts: 1

« on: May 10, 2017, 07:06:55 AM »

I have downloaded the XMetal Author 12 Version and want to customize the style of the Tag on View by using css.
I use the topic.dtd in my xml file.
My Question:
In which css file can I make this change e.g. change font color of the tag to red?

Thank for Help
Derek Read
Program Manager (XMetaL)

Posts: 2621

« Reply #1 on: May 10, 2017, 12:58:24 PM »

You can extend the CSS files used for DITA authoring, and specifically the topic.dtd, by adding selectors to this file:

C:\Program Files\XMetaL 12.0\Author\DITA\XACs\<dita version>\topic\topic_ditabase-specialized.css

The <dita version> is the folder used by the version of DITA you are authoring to, as set in Tools > DITA Options on the General tab under "Select Default DITA Version". In version 12 you can choose from 1.1, 1.2 or 1.3. The default version is 1.3.

Keep in mind that standard W3C CSS cascading rules apply. So, if you are overriding a previously defined CSS selector (which is very likely) any selector you add needs to be at least as "specific". Any property set on the other selector will also still be in effect unless you provide a new value for it. Also, all the selectors for DITA use the DITA @class for the element (not the element name). This allows them to automatically be applied to any elements in any specialized DITA DTD that specializes that element (ie: if you specialize to add a <para> element based on <p> then they will look the same). In order to be as specific (according to the CSS cascade rules) you need to follow the same format (which basically means using the class attribute).

To check which other values are previously set have a look at this file (and the files it imports):

C:\Program Files (x86)\XMetaL 12.0\Author\DITA\XACs\<dita version>\topic\topic_ditabase.css
C:\Program Files\XMetaL 12.0\Author\DITA\XACs\<dita version>\topic\topic_ditabase.css

That file just imports other CSS files, like so:

@import url(..\..\shared\ditabase-base.css);
@import url(..\ditabase\ditabase-base-override.css);
@import url(..\..\shared\ditabase-derived.css);
@import url(..\ditabase\ditabase-derived-override.css);
@import url(topic_ditabase-specialized.css);

...which is why you would normally add any of your own overrides or additional selectors to topic_ditabase-specialized.css

Of course you could also make modifications directly to any of these CSS files, it is just a bit cleaner to do it this way because then all of your changes are in one place. Adding them to topic_ditabase-specialized.css also means they are guaranteed to load last.

I would recommend commenting any changes you make with the date and reason. XMetaL Support often has clients contacting them for help with changes made to the software several years after they were done (not usually CSS, but macros and other functionality) when the creator is either now gone or doesn't know what they did or why. Makes it impossible to guess what the intended purpose for any particular change might have been.

Example that turns topic/p elements red for the topic.dtd for DITA version 1.3:

The CSS selector for this element is defined here (and imported by the other DITA CSS files):

C:\Program Files\XMetaL 12.0\Author\DITA\XACs\shared\ditabase-base.css

/* p */
[class~="topic/p"] {
   display: block;
   margin-top: 2px;
   margin-right: 2px;
   margin-bottom: 8px;

Modify this file:
C:\Program Files\XMetaL 12.0\Author\DITA\XACs\1.3\topic\topic_ditabase.css

Add something similar to this:
/* Derek Read
changed p element to make it red
because I needed it to stick out and be really obvious
[class~="topic/p"] {
color: red
« Last Edit: May 10, 2017, 07:16:43 PM by Derek Read » Logged
Pages: 1
Jump to:  

email us