How to target custom css to a specific post?

Posted in: Newspaper
Post count: 41

Hi,

I want to target custom css to a specific post, not site wide.
What code would I need to put where?
I tried a plugin but it causes a server error 500.

Thanks

Post count: 9544

Generally you can’t unless you create a custom template. Note CSS is very small if minified. Often you simply create a custom class like “.specialposty” and put that in your style.css at the bottom, or in the custom CSS box in theme panel.

.customposty{font-size:30px;border-bottom:4px:}

or whatever.

Then in your special post/page, just call that

<div class="customposty">
My special CSS for just this one page on site.
</div>

something like that.

If trying to modify existing classes on just one page; you might have to modify a template and name it after the post ID, where you would append a class to the existing inline classes. If that makes no sense, you might want to try different approach entirely.

  • This reply was modified 9 years by simchris.
Post count: 41

Thanks Chris 🙂

It’s a bit complicated, but I’ll rock my keyboard till I get it.

Post count: 22421

Hi,

If you want to target a specific post with css, you can also use the post ID: http://screencast.com/t/vXVijvABv
It’s one of the classes on the body tag.

Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.