0

I have this defined in an existing CSS sheet that I'm working with:

label.error-field

To assign this to an html element do I simply do class="error-field" or do I add the label to have it be class="label.error-field"?

0

5 Answers 5

4

This is the right way:

<label class="error-field">My Label</label>
Sign up to request clarification or add additional context in comments.

Comments

4

label.error-field is only applied to <label> elements with the class "error-field".

So if you want it on a label, then you'd just assign the class as "error-field", like this:

<label class="error-field">

Comments

3

This will only work on labels.

<label class="error-field">I'm an error label, yo ho ho</label>

The label. part is a CSS type (element) selector with a class (.) selector.

Comments

3

Add it simply to the label. class="error-field".

Comments

3

label.error-field will select an element label with a class of error-field

<label class="error-field">...</label>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.