WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to hide the overflow in CSS for specific template pages but can't seem to get it to work - I know that template pages are prefixed with a class but this doesn't seem to help targeting.

I think I could use the is_page_template() function to hide the overflow with JS but this should be simpler with CSS.

So this works...

html {
    overflow: hidden;

but this doesn't work...

html .page-template-showreel-php {
    overflow: hidden;

Any ideas why? Surely this should be possible with CSS.

share|improve this question
up vote 1 down vote accepted


html .page-template-showreel-php {
    overflow: hidden;

...will target body.page-template-showreel-php. So, two questions:

  1. Do you have the <?php body_class(); ?> template tag inside of the <body> HTML tag?
  2. Is hiding overflow on the <body> tag really what you're after, or do you need to target a descendant element?


There is no semantic or programmatic reason that you can't re-use the <?php body_class(); ?> template tag inside the <html> tag also. So, you might consider:

<html <?php body_class(); ?>>

and then:

html.page-template-showreel-php {
    overflow: hidden;

Worth a shot...

share|improve this answer
Hi Chip.. 1. Yes 2. What I am trying to achieve is hide the vertical scrollbar completely on the page. Normally I would just use html {overflow:hidden;} but in this case I only want to target a template page. Here is a link to help conceptualise what I'm trying to do... www.jaygeorge.co.uk/gwennan-sage/showreels The vertical scrollbar should be hidden because it's distracting and I would like the page to be button driven considering my target audience (non-web-savvy people who prefer clicking buttons over scrolling) – SparrwHawk Jun 25 '11 at 20:40
See answer update... – Chip Bennett Jun 25 '11 at 20:54
Hi Chip, That works great, thanks a lot. If you refresh jaygeorge.co.uk/gwennan-sage/showreels you can see your code working. Cheers, Jay – SparrwHawk Jun 25 '11 at 21:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.