- This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
Viewing 9 posts - 1 through 9 (of 9 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
How can I target pages with CSS in WordPress. I would like to spec different styles in the index.php, single.php, archive.php etc.
Those pages don’t have a unique opening body tag.
Have you set up your body tag like this:
>
Because that will spit out all of the selectors you could need.
YES!
How do I get started? I know very little about php.
Find your header.php file, that’s where you should have the body tag.
Simply replace:
with:
>
And check the results on your website.
Do I have to target the whole class?
or can I just use archive or single etc.?
You can target whichever you like!
If you want to target the category “marketingbytes”, for example, you could do this in your css:
.category-marketingbytes #wrapper #content a {
color: blue; /* Marketing Bytes links will be blue! */
}
What about just “archive” or “single?”
.archive h2 {}
That would work fine, too.
So ‘.archive h2’ would target all h2’s within any archive page.
single.php is used for posts, page.php is used for pages, etc etc.
That’s great. Thank you!