CSS CSS Selectors Going Further with Attribute Selectors and Pseudo-Classes Element States Pseudo-Classes

Mahima Gangavarapu
Mahima Gangavarapu
16,229 Points

Why are both the input:focus and textarea:focus are targeted in css?

Hello! Please help me:
I do not understand why both the input and textarea were targeted in the stylesheet :

input:focus,
textrea:focus
 {
  border-color: pink;

}

The border still appeared when I did not target the textarea

input:focus
 {
  border-color: pink;

}

Also, the border didn't appear when I targeted just the textarea and not the input field

textrea:focus
 {
  border-color: pink;

}

1 Answer

Steven Parker
Steven Parker
195,812 Points

At this point in the video, there are no "textarea" elements in the HTML. All of the boxes are "input" elements, and that explains what you observed. It's possible that the page design will be extended later by adding one ore more "textarea" elements, and that selector will become effective at that point. Otherwise, you're right, that selector isn't needed.

Also, I noticed that in both the examples above, you wrote "textrea" instead of "textarea". That would also prevent it from working (if there were any elements of that type).