In CSS, selectors are used to target the HTML elements on our web pages that we want to style. There are a wide variety of CSS selectors available, allowing for fine grained precision when selecting elements to style. In the next few articles we'll run through the different types in great detail, seeing how they work. Nov 18, 2015 - CSS Selector Helper for Chrome™ makes finding the right CSS selector on a web page much quicker and easier than digging through the.
CSS selectors define the elements to which a set of CSS rules apply. They are similar to in that they select a set of elements.
Simple selectors Selects all elements that match the given node name. Syntax: eltname Example: input will match any element. Selects all elements that have the given class attribute. Classname Example:.index will match any element that has a class of 'index'.
Selects an element based on the value of its id attribute. There should be only one element with a given ID in a document. Syntax: # idname Example: #toc will match the element that has the ID 'toc'. Selects all elements. Optionally, it may be restricted to a specific namespace or to all namespaces.
Syntax:. ns. Example:. will match all the elements of the document. Selects elements based on the value of the given attribute.
Syntax: attr attr= value attr= value attr = value attr^= value attr$= value attr.= value Example: autoplay will match all elements that have the autoplay attribute set (to any value). Combinators The + combinator selects adjacent siblings. This means that the second element directly follows the first, and both share the same parent. Syntax: A + B Example: h2 + p will match all elements that directly follow an. The combinator selects siblings. This means that the second element follows the first (though not necessarily immediately), and both share the same parent.
Syntax: A B Example: p span will match all elements that follow a. The combinator selects nodes that are direct children of the first element. Syntax: A B Example: ul li will match all elements that are nested directly inside a element. The (space) combinator selects nodes that are descendants of the first element.
Syntax: A B Example: div span will match all elements that are inside a element. The combinator selects nodes which belong to a column. Syntax: A B Example: col td will match all elements that belong to the scope of the. Pseudo-classes allow the selection of elements based on state information that is not contained in the document tree. Example: a:visited will match all elements that have been visited by the user.
Pseudo-elements represent entities that are not included in HTML. Example: p::first-line will match the first line of all elements. Specifications Specification Status Comment Working Draft Added the column combinator. Recommendation Added the general sibling combinator. Made pseudo-elements use a:: double-colon prefix.
Recommendation Added the child and + adjacent sibling combinators. Added the universal and attribute selectors. Recommendation Initial definition. See the and specification tables for details on those.
We 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. Chrome.
Click the Chrome Menu button in the top right corner. Hover over More Tools. 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. 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.
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.
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!. 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. Now it's time to head to HelpDocs. I'll go to Settings Code Custom CSS and paste in the CSS I just found. Phew, I'm almost there!
Time to change my link color (you can use to find a color). I'm going for #721DFE, a nice light purple. I'll simply replace the old color with my new one. 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 #maindata-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!