Have you sat back and thought to yourself something like this “It would be nice if our header was red on this page”? I’m sure you’ve wondered something similar at some point in time, so let me let you in on a little secret it super easy to do this, as WordPress has little CSS classes that will allow you make such changes quite simply. Today I just want to share these CSS classes with you.
These are some examples of what the main WordPress CSS classes look in action
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;”]LmhvbWV7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;”]LnBhZ2UtaWQtOTk5OXsKLypTb21lIENTUyovCn0=[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;”]LnBvc3RpZC05OTk5ewovKlNvbWUgQ1NTKi8KfQ==[/et_pb_dmb_code_snippet]
The first example is the homepage, the second is what the page class will look like and the third one is an example of what a post CSS class will look like.
Know that you know this kind of CSS classes exist you probably wondering how you can find your page or post CSS class.
If you can’t see the image properly just give it a click and it will enlarge, to find your page or post CSS class all you need to do is to right click and go inspect or developer tools or whatever your browser calls it.
Once you’re inspect element or developer tools are open, scroll top of the HTML code until you get to the body, you will notice the body has a bunch of classes attached to it, you’ll just need to look for the one which starts with page-id- or postid- they will be followed by number, just copy it and paste it into your CSS, you will need to put a full stop in front of it.
Now that I’ve shown you the slightly harder way of finding a page or post id let me show you easier option to find just the number that the class will have at the end.
The second option is quicker because all you have to do is look at the top of the post or page you are editing in the URL bar towards the end you will see a bunch of numbers that is the page or post id, you will just need to manually write the rest of the CSS class and add the numbers to end of the class.
Here a working Example, we changed element for this post
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;”]LnBvc3RpZC00OTc3MCAjbWFpbi1oZWFkZXJ7CmJhY2tncm91bmQ6IzFlMWUxZTsKfQoucG9zdGlkLTQ5NzcwICNtYWluLWhlYWRlciAubWVudS1pdGVtewpjb2xvcjojZDc2MDAwOwp9[/et_pb_dmb_code_snippet]
What about custom post types?
Custom post types use the same CSS class as a normal post dose (postid-9999) so there nothing really special about using custom post types but let say you wanted to hide a global element in your custom post type or even on one of the normal post types, WordPress has you covered.
Here what your custom post type class will look like.
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;”]LnNpbmdsZS1teWN1c3RvbXBvc3R0eXBlewovKlNvbWUgQ1NTCn0=[/et_pb_dmb_code_snippet]
Here are more WordPress & WooCommerce classes
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LnBhZ2V7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LnNpbmdsZS1wb3N0IHsKLypTb21lIENTUyovCn0=[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmNhdGVnb3J5ewovKlNvbWUgQ1NTKi8KfQ==[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmNhdGVnb3J5LTIwewovKlNvbWUgQ1NTKi8KfQ==[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmNhdGVnb3J5LXlvdXItY2F0ZWdvcnkgewovKlNvbWUgQ1NTKi8KfQ==[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LnNpbmdsZS1wcm9kdWN0ewovKlNvbWUgQ1NTKi8KfQ==[/et_pb_dmb_code_snippet]
That pretty much all the major CSS WordPress classes you will need to create different styled page items with CSS but since I know most of my audenice are from the Divi community, it’s only fair that I share some of the little hidden Divi classes with them, these are the styles that get added when you select a specific style in the customizer, or you when you use the page builder and also divi adds a browser and OS class, so here are the Divi CSS classes.
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmV0X3BiX3BhZ2VidWlsZGVyX2xheW91dCB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmV0X3JpZ2h0X3NpZGViYXIgewovKlNvbWUgQ1NTKi8KfQ==[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmV0X2xlZnRfc2lkZWJhciB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmV0X3ZlcnRpY2FsX25hdiB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmV0X2JveGVkX2xheW91dCB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmV0X2hlYWRlcl9zdHlsZV9jZW50ZXJlZCB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LnNpbmdsZS1wcm9qZWN0IHsKLypTb21lIENTUyovCn0=[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]Lm9zeCB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LndpbmRvd3MgewovKlNvbWUgQ1NTKi8KfQ==[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmNocm9tZSB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmdlY2tvIHsKLypTb21lIENTUyovCn0=[/et_pb_dmb_code_snippet]
[et_pb_dmb_code_snippet title=”CSS Snippet” style=”androidstudio” linenums=”on” usetabwidth=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_css_codesnippet_heading=”background:#d76000;||padding-right:3%;||padding-left:3%;||padding-top:1%;||padding-bottom:1%;||border-top-left-radius: 5px;||border-top-right-radius: 5px;||” header_font=”|on||on|” header_font_size=”18px” header_text_color=”#fcfcfc” custom_css_codesnippet_codearea=”border-bottom-right-radius:5px;||border-bottom-left-radius:5px;” custom_css_main_element=”margin-bottom:20px;”]LmxvZ2dlZC1pbiB7Ci8qU29tZSBDU1MqLwp9[/et_pb_dmb_code_snippet]
Knowing these CSS classes have come in handy for time and again, most of the time you will need to add a few together to achieve your desired look, The Divi Commerce plugin took makes use of the Divi classes to restyle the tabs container width to be 100% of the screen width.
I hope you will find this information informative and helpful when building your website. 🙂