For reliability I'd suggest giving class-names, or id
s to the elements to style (ideally a class
for the text-inputs, since there will presumably be several) and an id
to the submit button (though a class
would work as well):
<form action="#" method="post">
<label for="text1">Text 1</label>
<input type="text" class="textInput" id="text1" />
<label for="text2">Text 2</label>
<input type="text" class="textInput" id="text2" />
<input id="submitBtn" type="submit" />
</form>
With the CSS:
.textInput {
/* styles the text input elements with this class */
}
#submitBtn {
/* styles the submit button */
}
For more up-to-date browsers, you can select by attributes (using the same HTML):
.input {
/* styles all input elements */
}
.input[type="text"] {
/* styles all inputs with type 'text' */
}
.input[type="submit"] {
/* styles all inputs with type 'submit' */
}
You could also just use sibling combinators (since the text-inputs to style seem to always follow a label
element, and the submit follows a textarea (but this is rather fragile)):
label + input,
label + textarea {
/* styles input, and textarea, elements that follow a label */
}
input + input,
textarea + input {
/* would style the submit-button in the above HTML */
}