8

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?

2 Answers 2

21

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;" %>
Sign up to request clarification or add additional context in comments.

Comments

2

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;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.