Title: PHP generated inline CSS query
Last modified: August 18, 2016

---

# PHP generated inline CSS query

 *  [endpeg](https://wordpress.org/support/users/endpeg/)
 * (@endpeg)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/php-generated-inline-css-query/)
 * I’ve borrowed some code from this support forum so that I can generate an inline
   CSS style for the specific page a person is on. The navigation button is highlighted
   depending on what page of the site you’re on. I use this code to style the specific
   list element using inline CSS:
 * `<?php
    if ( is_home() ) { $current = 'b-home a'; } elseif ( is_page('about')){
   $current = 'b-abou a'; } elseif ( is_page('about-the-author') ) { $current = '
   b-abou a'; } elseif ( is_page('about-the-site') ) { $current = 'b-abou a'; } 
   elseif ( is_page('brief-resume') ) { $current = 'b-abou a'; } elseif ( is_page('
   archive-index') ) { $current = 'b-arch a'; } elseif ( is_page('links') ) { $current
   = 'b-link a'; } elseif ( is_page('contact') ) { $current = 'b-cont a'; } ?>
 * <style type="text/css">
    li#<?php echo $current;Â ?> { color: #fff; font-weight:
   bold; background: #62C061 url(/img/nav-focus.gif) repeat-x bottom left; } </style
   >
 * As im no expert on PHP what and where do I add to this code to style my list 
   elements if $current is none of these options/pages. eg. a comment page? I dont
   want any of my navigation buttons highlighted on most of the other pages so the
   site actually works correctly as it is – the only problem is it wont validate.
   Basically that means i only need the inline CSS on my main web pages.
 * Hope that makes sense to someone! Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [chiensavant](https://wordpress.org/support/users/chiensavant/)
 * (@chiensavant)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/php-generated-inline-css-query/#post-189883)
 * Humm.. not to me unfortunately.
    Could you provide us with some working example
   and with a page where it does not do what you want it to do ? I’m the kind of
   visual guy 😉
 *  [jinsan](https://wordpress.org/support/users/jinsan/)
 * (@jinsan)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/php-generated-inline-css-query/#post-189886)
 * Post a link to your site, and then perhaps someone can look at the validation
   for you and offer a better answer.
 *  Thread Starter [endpeg](https://wordpress.org/support/users/endpeg/)
 * (@endpeg)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/php-generated-inline-css-query/#post-190330)
 * The website’s at:
    [http://www.endpeg.com/](http://www.endpeg.com/)
 * Home, About, Archives etc are all highlighted when you’re on those pages. I just
   need a ‘catch all’ piece of code for the rest of the pages that dont get highlighted.
 *  Thread Starter [endpeg](https://wordpress.org/support/users/endpeg/)
 * (@endpeg)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/php-generated-inline-css-query/#post-190436)
 * Anybody?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP generated inline CSS query’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [endpeg](https://wordpress.org/support/users/endpeg/)
 * Last activity: [21 years, 1 month ago](https://wordpress.org/support/topic/php-generated-inline-css-query/#post-190436)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
