How to apply CSS to knowledge articles?

filipwuyts
Mega Contributor

Hi,

I'm trying to apply a custom CSS to the articles in our Knowledge Base. As per the procedure explained in Uploading and referencing CSS, I've created a style sheet in Content Management > Design > Style Sheets. I then inserted the link to my style sheet at the top of the article:

<link href="sys_id_of_stylesheet_record.cssdbx" rel="stylesheet" type="text/css"></link>

However, upon saving the article, this line is stripped and replaced with

<p>  </p>

I found a procedure to insert the CSS link in every knowledge article (Custom CSS style sheets in non-CMS pages - ServiceNow Guru ), but sadly, that didn't work either.

My instance is on Geneva.

Any help much appreciated!

Thanks in advance,

Filip

1 ACCEPTED SOLUTION

Perhaps we should take a step back here and take a look at your requirements. Do you want the same style applied to all your KB Articles or are you looking at multiple styles?



I'm guessing you want to have a uniform look and feel for all your KB Articles. In which case what I'm giving you may be a bit overkill. What you could do is update the kb_view or kb_view_customer UI Pages, by adding a line such as this to the top:


<link href="stylesheet_sys_id.cssdbx" rel="stylesheet" type="text/css"></link>



In that ServiceNowGuru link, there's a question mark in the URL. You don't really need that. The above format should be good enough.



If you are hesitant in modifying the kb_view UI Page, there is a reference in the Wiki where customisations to this UI Page are preserved under a new UI Page called kb_view_customer when upgrading to Knowledge Management v3 (Migrating to Knowledge Management v3 - ServiceNow Wiki ). This may require some testing, but I'm wondering if this behaviour can be leveraged for you.



Unfortunately, what we are doing with Templates and Default values to "force" in styles are just hacks for HTML fields. If we could get near full-fledged support for WYSIWYG editing that would be absolutely lovely.



So, I would suggest you also raise an Enhancement Request on HI for styling support in HTML fields. If there's a lot of requests for this, it will certainly drum up interest with the ServiceNow Developers and, potentially, push them forward on this.


View solution in original post

11 REPLIES 11

Hi @davidbird 

 

So sorry for missing your message. You will not find this in recent releases as Content Management is legacy (pre-Service Portal) functionality.

 

It would be worth posting a new question in the community for a more modern approach and with respect to your specific requirements. 

 

However, having said that, some care would need to be taken with how much styling you put into the Knowledge Article. The steps taken above are appropriate for viewing the article within UI16 (and maybe Polaris). But, there is the potential conflict with the styling of how it is rendered in the Service Portal, as the portal will have its own set of CSS/SCSS rules.

 

I hope this helps.

Hi Shahed,
Thank you - yes - I'm aware of potential CSS rule conflicts, but I'm keen to see what works. Styles that I have pasted into the "code" section of the content have worked very well, so far, but it would be ideal to have one CSS that could be used by all of our pages.
I will post a new question - thank you for your help.
Dave.