I\'m learning CSS. How to style input and submit button with CSS?
I\'m trying create something like this but I have no idea how to do
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):
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 */
}