Custom Note Formats in PDF via HTML/CSS
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 2
- Joined: Thu Jul 28, 2022 8:36 pm
Custom Note Formats in PDF via HTML/CSS
I'm trying to update my CSS style sheet to customize different note types with varied background colors and icons. The ultimate output is a DITA PDF based on HTML5 & CSS.
In addition to the standard note types in Oxygen DITA, I've created note elements with a type attribute of other and an othertype attribute of Quality or Safety.
When I generate the output, these special notes generate correctly with a heading that reads Quality or Safety rather than Notes. So far, so good.
Now I'm modifying the notes.css file in an attempt to have different background colors for the different note types. The notes.css file already does this for warnings and such. For example:
generates a pink Restriction note.
However, I cannot successfully select my custom note types.
Adding the following does nothing to change the background color of the other note type.
The following doesn't do anything either:
Ultimately, I'd like each othertype value to generate a note with a unique color and icon. So if the othertype is Quality I'd get a note with a blue background and a trophy icon; Safety might have an orange background and a life-preserver icon, etc.
Does anyone know how to do this?
In addition to the standard note types in Oxygen DITA, I've created note elements with a type attribute of other and an othertype attribute of Quality or Safety.
When I generate the output, these special notes generate correctly with a heading that reads Quality or Safety rather than Notes. So far, so good.
Now I'm modifying the notes.css file in an attempt to have different background colors for the different note types. The notes.css file already does this for warnings and such. For example:
Code: Select all
*[class~="topic/note"].note_restriction {
background-color: #ff3399;
}
However, I cannot successfully select my custom note types.
Adding the following does nothing to change the background color of the other note type.
Code: Select all
*[class~="topic/note"].note_other {
background-color: #00ccff;
}
Code: Select all
*[othertype=Quality] {
background-color: #00ccff;
}
Does anyone know how to do this?
-
- Posts: 663
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Custom Note Formats in PDF via HTML/CSS
Post by julien_lacour »
Hello Eileen,
Your custom rules are not applied because of rule priority in CSS, to make it short: longer the CSS selector, higher the priority.
You can use these selectors instead (matching with both @type and @othertype):
You can notice that I already added both Quality and Safety with their icons. Like this you have your final output
.
Note: The default notes icons size is 24x24, so for a better rendering you should keep these values for your custom icons.
Regards,
Julien
Your custom rules are not applied because of rule priority in CSS, to make it short: longer the CSS selector, higher the priority.
You can use these selectors instead (matching with both @type and @othertype):
Code: Select all
*[class~="topic/note"][type="other"][othertype=Quality] {
background-color: #00ccff;
background-image: url(svg/trophy.svg);
}
*[class~="topic/note"][type="other"][othertype=Safety] {
background-color: #ffaa00;
background-image: url(svg/life-preserver.svg);
}

Note: The default notes icons size is 24x24, so for a better rendering you should keep these values for your custom icons.
Regards,
Julien
-
- Posts: 38
- Joined: Mon Dec 05, 2022 3:24 pm
Re: Custom Note Formats in PDF via HTML/CSS
Hello all,
A sub-question to this topic! My wish is to remove the note title on top of the note.
I.e. making this change:
I found the css in the framework that write this Note: in the first line: in C:\Program Files\Oxygen XML Editor 24\frameworks\dita\css\core.
I succeed changing background and border colors in the custom CSS I've created.
Something like:
But I did not succeed removing this first line.
Can anyone help me?
Thank you in advance.
ML
A sub-question to this topic! My wish is to remove the note title on top of the note.
I.e. making this change:
00.png
Note:I found the css in the framework that write this Note: in the first line:
Code: Select all
*[class ~= "topic/note"]:before {
content: url('../img/note.svg') " Note: ";
}
I succeed changing background and border colors in the custom CSS I've created.
Something like:
Code: Select all
*[class~="topic/note"][type="danger"] {
background-color: rgba(255, 0, 0, 0.3);
border-color: #FF0000;
}
Can anyone help me?
Thank you in advance.
ML
You do not have the required permissions to view the files attached to this post.
-
- Posts: 39
- Joined: Mon Jul 25, 2022 11:18 am
Re: Custom Note Formats in PDF via HTML/CSS
Post by andrei_pomacu »
Hi,
In order to remove the first line you need to hide the child of the note node which contains the title.
Regards,
Andrei
In order to remove the first line you need to hide the child of the note node which contains the title.
Code: Select all
*[class~="topic/note"][type="danger"] {
background-color: rgba(255, 0, 0, 0.3);
border-color: #FF0000;
}
*[class~="topic/note"][type="danger"]> *[class~="note__title"] {
display:none;
}
Andrei
-
- Posts: 38
- Joined: Mon Dec 05, 2022 3:24 pm
Re: Custom Note Formats in PDF via HTML/CSS
Dear gentlemen,
While abusing your kindness, I did not succeed making the same thing for my HTML output
I found the Notes.css where the rules a written.
To change the Caution note color, I've made:
and it is working nice.
I've made some other changes to modify icon and colors for my custom note Skills (type:Other Othertype:Skills):
or
and these ones do not work.
It is probably in the way I isolate the "other" type.
Sorry I'm not a web developer and the CSS techno is still a discovery for me
Thanks in advance for your help,
BR
ML
While abusing your kindness, I did not succeed making the same thing for my HTML output

I found the Notes.css where the rules a written.
To change the Caution note color, I've made:
Code: Select all
*[class~="topic/note"].note_caution {
background-color: rgba(255, 0, 0, 0.3);
border-color: #FF0000;
}
I've made some other changes to modify icon and colors for my custom note Skills (type:Other Othertype:Skills):
Code: Select all
*[class~="topic/note"].note_other {
background-color: rgba(200,200,200,0.3);
border-color: #000000;
background-image: url(resources/images/skilllevel.svg);
}
Code: Select all
*[class~="topic/note"][type="other"][othertype=Skills] {
background-color: rgba(200,200,200,0.3);
border-color: #000000;
background-image: url(resources/images/skilllevel.svg);
}
It is probably in the way I isolate the "other" type.
Sorry I'm not a web developer and the CSS techno is still a discovery for me

Thanks in advance for your help,
BR
ML
-
- Posts: 663
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Custom Note Formats in PDF via HTML/CSS
Post by julien_lacour »
Hello,
Currently these CSS rules will not work because the @type and @othertype attributes are not propagated into the html output. I added an issue to resolve this.
To make this work for both PDF and WebHelp, follow these steps:
Regards,
Julien
Currently these CSS rules will not work because the @type and @othertype attributes are not propagated into the html output. I added an issue to resolve this.
To make this work for both PDF and WebHelp, follow these steps:
- Add an @outputclass attribute on the skills note:
Code: Select all
<note type="other" othertype="Skills" outputclass="Skills"> ... </note>
- Update the CSS rule:
Code: Select all
*[class~="topic/note"].Skills { background-color: rgba(200,200,200,0.3); border-color: #000000; background-image: url(resources/images/skilllevel.svg); }
- Create a publishing template with the following content:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?> <publishing-template> <name>Custom</name> <webhelp> <resources> <css file="custom.css"/> <fileset> <include name="resources/**/*"/> </fileset> </resources> <parameters> <parameter name="webhelp.show.main.page.tiles" value="yes"/> <parameter name="webhelp.show.main.page.toc" value="no"/> <parameter name="webhelp.top.menu.depth" value="3"/> </parameters> </webhelp> <pdf> <resources> <css file="custom.css"/> </resources> </pdf> </publishing-template>
Regards,
Julien
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service