Using CSS to style Ruby objects in erb

I have Googled around but can't find the answer to this question. How do I use CSS to edit RUby objects in erb. For example:

<%= f.label :email, "Enter your email address for updates" %><br />
<%= f.text_field :email %>

Here, I want to use CSS to style the text and the form box. How can I do that?


You can use the :class option to specify a CSS class:

<%= f.text_field :email, :class => "login" %>

and then put that in your css:

input.login {
  color: red;

Also, you can specify inline CSS if you want:

<%= f.text_field :email, :style => "color: red;" %>

Adding on to what Dylan said...

You can use :id option to specify a CSS id:

<%= image_tag "illustrations/clipboard.png", :id => "clipboard" %>

and then put in your css:

#clipboard {
     border: 1px solid #000;

Need Your Help

Why does Maven warn me about encoding?

java maven maven-archetype

My goal is to create an archetype from a project.

Any easy, generic way in Android to get the root View of a layout?

android android-layout

I'm wondering if there is a general-purpose method in the Android Activity class to allow you to get the root View of that Activity's layout. I know I can do it this way: