Search code examples
csscolorsborder

CSS class won't override border-style


I have styled all my text fields with a gray border, and for the fields with class="form_field_error", I want the border-color to change to red.

I have tried the following code, but I can't get my class to override the previously defined border? What am I missing?

HTML:

<input type="text" name="title" id="title" class="form_field_error">

CSS:

input[type="text"] {
    display: block;
    height: 15px;
    font-weight: normal;
    color: #777;
    padding: 3px;
    border-top: 1px solid #aaa;
    border-left: 1px solid #aaa;
    border-bottom: 1px solid #ccc;
    border-right: 1px solid #ccc;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
}

.form_field_error {
    border: 1px solid #f00;
}

I created a jsFiddle to illustrate the problem.


Solution

  • Try this:

    .form_field_error {
        border: 1px solid #f00 !important;
    }