Finding CSS Selectors from Your Browser

by Jarratt Isted

One of the awesome things with HelpDocs is that it's just so customizable and getting it to fit in with your brand is a piece of cake. The easiest way to do this is to use Custom CSS. But getting CSS to work can be tricky, particularly if you're not a developer. 

We aren't able to provide you with custom code, but we hope this guide will help you find what you're looking for! 🙃

Here's a guide on how to target elements on your knowledge base and customize them to match your brand.

Finding the Developer Console in Your Browser

The very first thing you'll need to do is find the developer console in your browser. 

Don't worry—there's nothing to be scared about here. The developer console is an easy way to view the elements of a page and edit them live without actually changing the code. 

With the console, we'll just want to view the CSS selectors we've added, so you can effectively target them and change the way your knowledge base looks.

👈 Find your browser from the list on the left to understand how to open the developer tools.

Chrome

  1. Click the Chrome Menu button in the top right corner 
  2. Hover over More Tools
  3. Click Developer Tools

You can also use your keyboard using these shortcuts:

  • Mac: Use Ctrl+Opt+I 
  • Windows:  F12, Ctrl+Shift+I 
Already know the element you want to target? Simply right click and click Inspect. This will bring up the CSS selectors for that element.

Safari

  1. Click Safari > Preferences in the top menu bar
  2. In the Advanced tab, tick Show Develop menu in menu bar
  3. In the top menu bar, you'll see a new menu named Develop
    1. Click Develop > Show Web Inspector

You can also use your keyboard using this shortcut:

  • Mac: Use Ctrl++I 
Already know the element you want to target? Simply right click and click Inspect Element. This will bring up the CSS selectors for that element.

Microsoft Edge

  1. Press F12 on your keyboard
  2. Click DOM Explorer

You can also use your keyboard using these shortcuts:

  • Windows:  Ctrl+Shift+I 
Already know the element you want to target?

First, enable Inspections by entering about:flags in the URL bar, then tick Show "View Source" and "Inspect Element" in the context menu. Then, right click and press Inspect Element to view the CSS selectors for that element.

Internet Explorer

  1. In the top menu bar, click Tools > Developer Tools

You can also use your keyboard using these shortcuts:

  • Windows:  F12 
We strongly recommend switching to Microsoft Edge if you're using Internet Explorer. It no longer receives updates.
Already know the element you want to target? Open the developer menu (F12) and press Ctrl + B. Then, click the element you want to target.

Firefox

  1. In the top menu, click Tools > Web Developer > Inspector

You can also use your keyboard using these shortcuts:

  • Mac: Use Ctrl+Opt+I 
  • Windows:  Ctrl+Shift+I 
Already know the element you want to target? Simply right click and click Inspect Element. This will bring up the CSS selectors for that element.

Opera

  1. On Mac
    1. In the top menu bar, click Page > Developer Tools > Opera Dragonfly
  2. On Windows
    1. In the top menu bar, click Tools > Advanced > Opera Dragonfly

You can also use your keyboard using these shortcuts:

  • Mac: Use Ctrl+Opt+I 
  • Windows:  Ctrl+Shift+I 
Already know the element you want to target? Simply right click and click Inspect. This will bring up the CSS selectors for that element.

Finding the Correct CSS Selectors

Fantastic! So, by now you should be able to bring up your developer console by either using the menu or by inspecting an element on the page. Good job so far. You're well on your way to being able to customize your HelpDocs 👍

Now, let's go through an example. I'll be using the Chrome DevTools to change all link colors on articles from pink to purple.

  1. First, I'm going to open an article with a link in. Then, I'll Right Click on top of the element and click Inspect.


  2. My console will pop up with the selected element information. On the left is the HTML and on the right is the CSS. I'll need to look at the CSS. 

    Looks like I've found the CSS Selectors. I can tell because the console shows me some CSS which looks pretty familiar (color: #f71172 !important;). The box next to it indicates a pink color, which is exactly the same as my link color. It also shows p > a which can translated as paragraph > link.

    It also shows data-hd-template="boxedinstantv3", which is the layout I'm currently using. Looks perfect!

  3. Now I've found the element I'm looking for, I'll copy the information so I can use it in my own CSS in HelpDocs. I won't copy the link in the top right because it's not part of the CSS.

  4. Now it's time to head to HelpDocs. I'll go to Settings > CodeCustom CSS and paste in the CSS I just found.

  5. Phew, I'm almost there! Time to change my link color (you can use this tool to find a color). I'm going for #721DFE, a nice light purple. I'll simply replace the old color with my new one.

  6. I'll hit Save and now my link colors are all purple instead of pink! 🎉 

That's pretty much it. The general rule of thumb with choosing your CSS selectors is the more, the better

In the example above I targeted #main[data-hd-template="boxedinstantv3"] #article #body p > a, but had I targeted #article a it probably wouldn't have worked. Try to use specific selectors rather than general ones.

Good luck and have fun customizing your HelpDocs! 👩‍🎨


How Did We Do?