1. Target Individual Pages or Posts With CSS
The best way to target a specific page with CSS in Divi is to first find the ID of the page. This can be found in several ways.
A. Find Page ID From the “Edit Page” slug
The simplest way to find the CSS class of the page you want to target is to find the page ID in the slug of the page editor. This is super easy to find. Just go to the page you want to target, edit the page, and look in the address bar for something like this: https://yourdomain.com/wp-admin/post.php?post=291&action=edit
Do you see any numbers? That’s right! The page ID that you need for your CSS is right there, 291.
So how would this be used? The number gets added to the CSS selector of “.page-id-“ and becomes “.page-id-291”
So an example would be like this:
Where To Paste The CSS Code
1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the CSS tab in the custom code window in the Divi Visual Builder.
2. Child Theme
If you are using a child theme, paste this code into the style.css file. If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.
3. Divi Theme Options Integration
Otherwise, paste this code in your Divi>Theme Options>Custom CSS code box.
If you need help understanding where to paste the code, please check out our complete guide about where to add custom code In Divi.
Now this page is the only page on your website that will have the background color of red applied to it. This can be very handy for targeting more specific elements on your page like the header or menu item.
NOTE: For blog posts, it will be very similar, but the CSS selector will be “postid-“ instead, so for example “.postid-52”
B. Find Page ID Using the browser’s Inspect tool
This other method is for those how are familiar with the browser inspect tool. When you right-click on your website, you will see something like “inspect” or “inspect element.” Click on that and look for a button in the new, scary-looking code popout that looks like a mouse pointer. Select that pointer and click something on the page. Then, in the code popout, look for something near the top that starts with this:
<body class=”page-template-default page page-id-291 etc. etc.
Did you notice it? There it is, the “.page-id-291” that we need to target this Divi page with CSS. You can apply your CSS the same way as in the previous example.
Again, this is the same for blog posts. Just look for the “postid” on in the code.