input type text CSS selector does not apply to default-type text inputs

0 votes

Text is the default input type. Since the type was not expressly defined on the control, I have always thought that CSS declarations aimed at input[type='text'] would nonetheless have an impact on those inputs. But I've recently realised that the styles are not applied to my default-type text inputs. How come this is the case? And how do I deal with this?

input[type='text'] {
  background: red;
}
<input name='t1' type='text' /> /* Is Red */
<input name='t1' /> /* Is Not Red */
Jun 27, 2022 in CSS by Edureka
• 13,620 points
1,609 views

1 answer to this question.

0 votes
Because that is not what it is supposed to do.

The attribute selector input[type=text] will only select elements with the matching attribute.
answered Jun 28, 2022 by Edureka
• 12,690 points

Related Questions In CSS

0 votes
0 answers

input[type='text'] CSS selector does not apply to default-type text inputs?

Text is the default input type. Therefore, ...READ MORE

Aug 12, 2022 in CSS by Edureka
• 13,620 points
538 views
0 votes
1 answer

CSS text-overflow: ellipsis; not working?

So, if you've arrived at this question ...READ MORE

answered Jun 10, 2022 in CSS by Edureka
• 12,690 points
4,662 views
0 votes
1 answer

How to create material design input form using css and bootstrap?

Try with this code. HTML: <div class="main_div"> ...READ MORE

answered Jun 21, 2022 in CSS by Edureka
• 12,690 points
2,493 views
0 votes
1 answer

asp.net master page css not applying to asp form pages

just try the following code: <head> ...READ MORE

answered Jun 13, 2022 in CSS by Edureka
• 12,690 points
2,469 views
0 votes
1 answer

wildcard * in CSS for classes

Yes you can do this. *[id^='term-']{ ...READ MORE

answered Jun 21, 2022 in CSS by Edureka
• 12,690 points
640 views
0 votes
1 answer

jQuery vs document.querySelectorAll

As seen above, querySelector() methodcan only be used ...READ MORE

answered Jun 14, 2022 in JQuery by gaurav
• 23,260 points
4,594 views
0 votes
0 answers

Combinators in CSS

everyone! I am quite new to HTML ...READ MORE

Jul 8, 2022 in CSS by Edureka
• 13,620 points
349 views
0 votes
0 answers

CSS :not(:last-child):after selector

I have a list of elements, which ...READ MORE

Jul 11, 2022 in CSS by Edureka
• 13,620 points
2,452 views
0 votes
1 answer

How to insert spaces/tabs in text using HTML/CSS

For spaces, use &nbsp;, for (less than, ...READ MORE

answered Jun 1, 2022 in CSS by Edureka
• 12,690 points
623 views
0 votes
1 answer

How to combine input:after:focus pure css?

One method is to create an element ...READ MORE

answered Jun 1, 2022 in CSS by Edureka
• 12,690 points
1,322 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP