cookiejar
asked on
CSS Contextual Selectors
I trying to wrap by head around selecting the correct element on the html page within CSS.
In html
<fieldset id="commentFS">
<label>
Username
<input name="username" id="username" required="required"
title="Supply your username" />
</label>
<label>
Comment <br /> (500 character limit)
<textarea name="commentBox" id="commentBox" maxlength="500"></textarea >
</label>
<p>
<input type="submit" value="Submit Comment" />
</p>
</fieldset>
If I want to apply the same style rule to the input box and the textarea, do I create my selector as follows:
label input, label textarea {};
if I want to change the background color of the input boxes and the textarea, when they have focus, do I create the selector as follows ?
input:focus, textarea:focus {
background-color: rgb(225, 225, 240);
}
Is it necessary to prefix both with label?
In html
<fieldset id="commentFS">
<label>
Username
<input name="username" id="username" required="required"
title="Supply your username" />
</label>
<label>
Comment <br /> (500 character limit)
<textarea name="commentBox" id="commentBox" maxlength="500"></textarea
</label>
<p>
<input type="submit" value="Submit Comment" />
</p>
</fieldset>
If I want to apply the same style rule to the input box and the textarea, do I create my selector as follows:
label input, label textarea {};
if I want to change the background color of the input boxes and the textarea, when they have focus, do I create the selector as follows ?
input:focus, textarea:focus {
background-color: rgb(225, 225, 240);
}
Is it necessary to prefix both with label?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.