# How to apply class from Stylesheet to "link\_to" element?

**URL:** <https://www.ruby-forum.com/t/how-to-apply-class-from-stylesheet-to-link-to-element/56798>\
**Category:** Rails\
**Created:** [April 4, 2006, 8:36am UTC](https://www.ruby-forum.com/t/how-to-apply-class-from-stylesheet-to-link-to-element/56798 "2006-04-04T08:36:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 4, 2006, 8:36am UTC](https://www.ruby-forum.com/t/how-to-apply-class-from-stylesheet-to-link-to-element/56798/1 "2006-04-04T08:36:52Z")

</div>

# Hi, This is the “img” class for anchor element inside my stylesheet.

A.img:link {

```
color: #ffffff;
text-decoration: none;

```

}

# A.img:visited { color: #ffffff; text-decoration: none; }

# I can easily apply this tag inside my html document as follows:-

# \< a href=“goodbye.html” class=“img”\>

Now I want to apply this stylesheet class (img) to following link\_to tag  
of rHtml. How to this??  
\<%= link\_to “GoodBye!”, :action =\> “goodbye” %\>

===

Please help me .  
Thanx in advance.  
Prash

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 4, 2006, 9:36am UTC](https://www.ruby-forum.com/t/how-to-apply-class-from-stylesheet-to-link-to-element/56798/2 "2006-04-04T09:36:35Z")

</div>

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 4, 2006, 1:28pm UTC](https://www.ruby-forum.com/t/how-to-apply-class-from-stylesheet-to-link-to-element/56798/3 "2006-04-04T13:28:47Z")

</div>

> =======  
> \< a href=“goodbye.html” class=“img”\>  
> \<%= link\_to “GoodBye!”, :action =\> “goodbye” %\>
> 
> ===  
> Try…

\<%= link\_to “GoodBye!”, {:action =\> ‘goodbye’}, {:class =\> ‘img’} %\>

Braces are optional if all the following parameters are part of the  
unbraced hash…in this case, :class doesn’t belong in the same hash as  
the url\_for parameters, so you have to explicitly tell ERb where the  
hashes start and end…

Hope it helps!

Gustav P.  
removed\_email\_address@domain.invalid
