Restricting CSS
-
How do I restrict custom CSS to a particular part? Pages or a custom post type for example?
-
Hi there!
Have you looked into using a plugin:
https://ww.wp.xz.cn/plugins/search.php?q=custom+cssThere are quite a few that you can look into. I haven’t personally used those only because I don’t modify CSS much for posts/pages.
Castaneda,
The only plugins I have found for CSS only restrict CSS to the site as a whole, or to a particular post or page. I’m talking about restricting CSS to a particular template.
CSS itself can target specific areas of a page and specific pages, as long as there is some unique HTML to that area and page. Themes that are distributed on ww.wp.xz.cn have a unique class in the
<body>element, something like ‘page-id-56’, that you can use in CSS.Andrew,
I’ll check it out. Thank you.
Andrew,
Where would I find the <body> element in 2014>
Are there any templates in 2013, 2014, or 2015 with the <body> element?
Yes every single theme distributed on ww.wp.xz.cn has the
<body>element. For CSS, you only need to look at the generated code on your website and not look into the PHP files themselves.
The generated code can be seen when you right click on a page and select the ‘View source’ option.Some browsers, or some addons in browsers, let you see that code in a much neater way. Have you tried the Firebug addon for Firefox?
That’s where they hide it. π
Andrew,
Your suggestion didn’t work. So I’m going to try “page, p”
And it worked. And there was much rejoicing.
Not sure what you mean, I see the the unique class of ‘page-id-232’ on that page:
<body class="page page-id-232 page-child parent-pageid-230 page-template-default styles header-image footer-widgets singular">But then I deleted the “p” and the columns disappeared.
What columns are you referring to?
Andrew,
Not a particular page, pages in general.
The topic ‘Restricting CSS’ is closed to new replies.