# Tags in stylesheets

**URL:** <https://www.ruby-forum.com/t/tags-in-stylesheets/92095>\
**Category:** Radiant CMS\
**Created:** [April 16, 2007, 1:46am UTC](https://www.ruby-forum.com/t/tags-in-stylesheets/92095 "2007-04-16T01:46:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marshal\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@Marshal\_L](https://www.ruby-forum.com/u/Marshal_L)\
**Post date:** [April 16, 2007, 1:46am UTC](https://www.ruby-forum.com/t/tags-in-stylesheets/92095/1 "2007-04-16T01:46:24Z")

</div>

Hi all.

I’m putting together a site with Radiant (love the ease of use and  
flexibility – thanks to everyone involved in the project). From what  
I’ve read in the mailing list archives, I should be able to use radius  
tags in my stylesheet, just like other pages, to dynamically  
create/change the content.

For example, if I wanted the background color of the “about” page to  
be different than the other pages, something like this should work:

body {  
background-color: #d7dba9;  
\<r:if\_url matches="/about/"\>background-color: #009a3b;\</r:if\_url\>  
font-family: Verdana, Arial, Helvetica, sans-serif;  
font-size: 80%;  
etc…  
}

but it doesn’t.

My stylesheet is a Radiant page, just like the style.css created with  
the type 3 (styled blog) install of Radiant. When I view the generated  
css file in my browser, a blank line appears in place of the line with  
the tags:

body {  
background-color: #d7dba9;

```
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 80%;
etc...

```

}

Any ideas? Have I missed something obvious? Thanks for any help.

PS. This is a trivial example. I could get the different colored  
background easily with

 in the page layout and body#about { background-color: #009a3b; } in the stylesheet.

---

<div class="post-metadata">

**Author:** ![Marshal\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@Marshal\_L](https://www.ruby-forum.com/u/Marshal_L)\
**Post date:** [April 16, 2007, 2:02am UTC](https://www.ruby-forum.com/t/tags-in-stylesheets/92095/2 "2007-04-16T02:02:25Z")

</div>

Keep in mind that your stylesheet is rendered just like a Radiant page.  
If you’re linking it in the traditional pattern, \<r:if\_url /\> will try  
to match the URL of the stylesheet, not the HTML page being viewed. This  
is because the request to get the stylesheet is not the same request as  
the one to get the page.

You might try putting some code like this in your main layout:

...

Then in your pages that need specific changes to the style, make a  
“styles” tab/part and dump the special styles in there. So on the  
“About” page that has the url “/about/”, you could put this:

body {  
background-color: #009a3b;  
}

This would accomplish what you want, and be more flexible.

Sean

---

<div class="post-metadata">

**Author:** ![Marshal\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ccd318/32.png) [@Marshal\_L](https://www.ruby-forum.com/u/Marshal_L)\
**Post date:** [April 16, 2007, 5:49am UTC](https://www.ruby-forum.com/t/tags-in-stylesheets/92095/3 "2007-04-16T05:49:37Z")

</div>

Thanks Sean. I thought it might be something like that. Appreciate  
your explanation.
