💡CSS - Attribute Selectors you probably don't know about.

A thread...

#webdevelopment #webdesign #webdeveloper #html #website #coding #programming #css #javascript #development
1. Select element(s) having attribute of name ‘attr’. No matter what the value is.
👉 [attr]
Try it on Codepen: codepen.io/junaidshaikh_j…

#webdevelopment #webdesign #webdeveloper #html #website #coding #programming #css #javascript #development Image
2. Select element(s) having the attribute of name ‘attr’ whose value is having an exact match to ‘value’
👉 [attr = value]
Try it on Codepen: codepen.io/junaidshaikh_j…

#webdevelopment #webdesign #webdeveloper #html #website #coding #programming #css #javascript #development Image
3. Let’s say one of your elements has a class attribute having multiple classes separated by whitespace and you wanted to match the selector to one of the values in the list.
👉 [attr ~= value]

#webdevelopment #webdeveloper #html #website #coding #css #javascript
This selector will select an element having an ‘attr’ attribute whose value contains ‘value’ as an exact match in the list. (~ this character is called tilde)
Try it on Codepen: codepen.io/junaidshaikh_j…

#webdevelopment #webdeveloper #html #website #coding #css #javascript Image
4. Select element(s) having the attribute of name ‘attr’ whose value starts with ‘value’
👉 [ attr ^= value ]
Try it on Codepen: codepen.io/junaidshaikh_j…

#webdevelopment #webdesign #webdeveloper #html #website #coding #programming #css #javascript #development Image
5. Select element(s) having the attribute of name ‘attr’ whose value contains ‘value’ anywhere in the string
👉 [attr *= value]
Note: This value isn’t the exact match like [attr ~= value]
Try it on Codepen: codepen.io/junaidshaikh_j…

#javascript #CSS #webdevelopment #html Image
6. Select element(s) having an attribute of name ‘attr’ whose value ends with ‘value’
👉 [attr $= value]
Try it on Codepen: codepen.io/junaidshaikh_j…

#webdevelopment #webdesign #webdeveloper #html #website #coding #programming #css #javascript #development Image
7. Select element(s) having the attribute of name ‘attr’ whose value is the exact match of ‘value’ or having the value of ‘value’ which is immediately followed by hyphen (-)
👉 [attr |= value]
Try it on Codepen: codepen.io/junaidshaikh_j…

#webdevelopment #html #css #javascript Image
That's all for this thread. If you find this helpful, retweet the thread😃

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Junaid ⚡

Junaid ⚡ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @junaidshaikh_js

16 Jul
10 VS Code extensions that will help you to be more productive 💪

A thread...

#100DaysOfCode #CodeNewbie #vscode #webdevelopment
1. Prettier

Prettier is the code formatter extension. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

🔗marketplace.visualstudio.com/items?itemName…

#100DaysOfCode #CodeNewbie
2. Simple React Snippets

If you are a React developer, check out this extension that provides an essential collection of React Snippets and commands

🔗marketplace.visualstudio.com/items?itemName…

#100DaysOfCode #CodeNewbie #vscode #webdevelopment
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(