Sergio Tapia
Sergio Tapia

Reputation: 41218

How can I apply CSS to an HTML text input?

Here is the ASP.Net MVC2 code that I use to display a textbox input.

<div id="blackbar">
    <p>Sistema de Evaluaciones de Docentes</p>
    <%: Html.TextBox("termino","") %>
    <img src="../../Content/search.png" alt="search" />
</div>

Here is how it renders:

<div id="blackbar">
    <p>Sistema de Evaluaciones de Docentes</p>
    <input id="termino" name="termino" type="text" value="" />
    <img src="../../Content/search.png" alt="search" />
</div>

How would I use CSS for example to give the textbox a red border? How can I tell MVC2 to give this text input a class or something?

EDIT: I've tried the following, but the text I write into the input isn't green.

.textinput
{
    color:Green;
}

<%: Html.TextBox("termino", "", new { @class = "textinput" })%>

Upvotes: 1

Views: 257

Answers (4)

Philip Smith
Philip Smith

Reputation: 2801

To style all text boxes in the blackbar div you can use:

#blackbar input[type='text'] { ... }

Upvotes: 0

hunter
hunter

Reputation: 63562

<%=Html.TextBox("termino", "", new { @class = "redborder" }) %>

Upvotes: 6

David Thomas
David Thomas

Reputation: 253486

input[name=termino],
input#termino,
#termino
{
border: 1px solid #f00;
}

Upvotes: 0

C Bauer
C Bauer

Reputation: 5103

#termino { border: solid 1px #F00; } 

Upvotes: 0

Related Questions