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 in CSS by Edureka
• 9,940 points
37 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 by Edureka
• 9,540 points

Related Questions In CSS

0 votes
1 answer

CSS text-overflow: ellipsis; not working?

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

answered Jun 10 in CSS by Edureka
• 9,540 points
364 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 in CSS by Edureka
• 9,540 points
108 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 in CSS by Edureka
• 9,540 points
77 views
0 votes
1 answer
0 votes
1 answer

wildcard * in CSS for classes

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

answered Jun 21 in CSS by Edureka
• 9,540 points
26 views
0 votes
1 answer

jQuery vs document.querySelectorAll

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

answered Jun 14 in JQuery by gaurav
• 17,580 points
62 views
0 votes
0 answers

Combinators in CSS

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

Jul 8 in CSS by Edureka
• 9,940 points
11 views
0 votes
0 answers

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

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

Jul 11 in CSS by Edureka
• 9,940 points
10 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 in CSS by Edureka
• 9,540 points
24 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 in CSS by Edureka
• 9,540 points
101 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP