Originally posted on my blog
Selectors in CSS are used to pick elements and style them. They can be very powerful following which one we use. In...
For further actions, you may consider blocking this person and/or reporting abuse
Probably should tag this with #beginer
Yeah I also thought I was about to learn something new ;/
Not sure. The regex-like selectors are often times forgotten.
I'll add the beginner tag. Thanks
Yes, should be tagged as beginner, however it is good from time to time to refresh our knowledge and this was a perfect opportunity. Thanks a lot! Have a great day! R.
I'll add the beginner tag and thanks for your comment and have a great day too.
What about selecting an a before a div?
<a></a>
<div></div>
Is this possible?
What you're describing is a "previous sibling" selector and it doesn't exist in CSS. Another popularly desired selector that doesn't exist is a "parent selector." While they both can be implemented in JavaScript pretty easily, the spec-writing gods of CSS, and the algorithm writers who implement those specifications have their reasons for denying us these things.
The reasons come down to performance. We can see this from a couple of snippets from the Selectors Level 4 spec, where it discusses the Live and snapshot profiles
In this particular case
<a>
before<div>
could be done using thehas()
pseudo-class asa:has(+ div)
ora:has(~ div)
, buthas()
is only part of the snapshot profile and therefore not for implementation in CSS.Very useful thank you
I'm glad that you find it useful, Thanks for your comment.
Very useful tips. Thank you!
I'm glad that you find it useful, Thanks for your comment.
Great job
Thanks for your comment.
Some of these are really helpful and easy to understand, thanks
I'm glad that you find it useful, Thanks for your comment.
Yes, it's common selectors but useful, thanks
Thanks a lot for your comment.
good
Thanks
No matter this would help in writing clean code or not, but thanks for a quick recall to some of the unconventional selectors, which may surely help to style some typically written html 😁
Thanks
Nicely put. Thanks for the tips, good work done.
I'm glad it could help, Thanks for your comment.
Btw just realized that,
*, $, ^ are all valid Regex quantifires. 🤯
That's it..regex is super powerful.
Really good article. Thanks
Thanks for your comment.
You might want to review your html markups, they wrongly type and will confused a learner.
Powerfull css selector are the pseudo selector
Yeah, I knew these too. But, so what? He took the time to write the article, and I am sure others will find it useful. Nice job!
Thanks man!