According to the W3 CSS spec, something like: input[type~="text password"]
should select input fields whose type is set to either "text" or "password", but it doesn't work! Did I misinterpret this line?
E[foo~="warning"] Matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning".
CSS spec source, it's the fourth from the bottom in the table.
A CSS selector can contain more than one simple selector. Between the simple selectors, we can include a combinator.
CSS class selector The class selector selects HTML elements that have a class attribute that matches the selector. The class selector is useful for targeting multiple elements, things like cards or images that you want to have matching styles. To select an element with a specific class, you use a .
Yep, you've got it round the wrong way. The selector is to search within a space seperated list.. i.e.
<element attribute="text password" />
you could find using:
element[attribute~="text"]
The benefit of this is that it shouldn't match:
<element attribute="textual password" />
Hope that helps?
To achieve what you're actually trying to do is a bit more verbose:
input[type="text"], input[type="password"]
Just follow this:
html:
<div class="contact-form"> <label for="">Name</label> <input type="text"> <label for="">Email</label> <input type="email"> <label for="">Subject</label> <input type="text"> <label for="">Message</label> <textarea></textarea> <input type="submit" value="Send"> </div>
css:
.contact-form input[type="text"], input[type="email"]{ width:100%; box-sizing:border-box; border:1px solid black; padding:5px; } .contact-form input[type="submit"]{ display:block; color:black; background-color:white; border:1px solid black; border-radius:10px; margin-top:10px; padding:10px; cursor:pointer; margin:auto; margin-top:20px; }
I hope you understand it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With