-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[selectors4] :target-within? #457
Comments
Seems like a good idea to me |
+1 |
The Working Group just discussed
The full IRC log of that discussion<eae> Topic: Target within<astearns> github: https://github.com//issues/457 <bradk_> i think "filter()" vs. "filter:" would lead to confusion <eae> leaverou: This is probably best explained with an example. Image a photo gallery, clicking a phot enlarges it, often done with pseduo and having an anchor with a hash url. Every time you click an image it becomes the target. <eae> leaverou: You also want to apply a style to the entire gallery without a selection, also done with target. <eae> leaverou: No way to target the state where there is no hash. <eae> leaverou: Suggested this on github but got no comments. Think it is useful and not terrible difficult to implement. <eae> TabAtkins: I see the use case and see similar uses, I'm supportive of the use case. <eae> ???: What if you have a photo gallery that also has some sections that aren't images that are stil targetable by a hash? <eae> leaverou: Another use case for target-within as it allows both for the selected image and not to be supported. <dbaron> s/???/dholbert/ <tantek> +1 <eae> Rossen: Any objections to target within? <eae> RESOLVED: Add target within to selectors 4. <leaverou> s/as it allows both for the selected image and not to be supported./as it allows you to use it on the image, which will apply both when the image is target or when it contains a target/ |
A more general way of selecting parent elements, rather than confining the ability :focus-within and :target-within, would be amazing. They're a nice start though. I've already found using :focus-within very useful. |
The way I see it, Isn't If the general pattern of
Adding each of these would add quite a bit more of
I've experimented quite a bit with selecting parents and ancestors in CSS and I have found it useful, and I've even tried to DIY support like
Alternatively to speccing a ton of newer, weaker, more limited selectors that do small aspects of what |
We should really have an FAQ for this… I do agree that duplicating syntax is not great though. If it were up to me, I'd just special case |
There’s an alternative to @LeaVerou’s idea (i.e., her idea to turn The alternative choice is to revise the current Selectors Level 4 draft so that Moreover, the current draft’s slow/general version of In this way, the shorter word But no matter the choice made, ultimately, authors would probably use the fast/enumerated pseudo-class (i.e., in both general CSS and JavaScript/DOM) far more than the slow/general pseudo-class would probably ultimately be used by authors much less often (i.e., in JavaScript/DOM only). Yet another alternative choice: The current draft’s slow/general |
Add :target-within to Changes section w3c/csswg-drafts@0fdb0f8ec4b9d6dcb2302715ee4ab 35013a1a000 Add :target-within, resolves w3c/csswg-drafts#457 w3c/csswg-drafts@d517bca980d01d13a1dc3765c0a3a 059c948402e Add :focus-within to Overview w3c/csswg-drafts@0933c5482c1ac25edf165e6c7b28c 66f1e561780 Add :is() example in specificity section, and add it in… w3c/csswg-drafts@a9fddaf185d9885bd657cd222956b ccc35486939 Add :is(), resolves w3c/csswg-drafts#1170 w3c/csswg-drafts@5948b1ce37463aa7f87fede040fac 9dd2c233329 Remove issue about :any-link naming, now that it's widely implemented. w3c/csswg-drafts@33ae0979aff2c9a87cbd1e0f15ce5 632b1b1eaf3
FWIW, What I want to say is that, the implementation of Also we are always lack of room for more flags to track on elements, which means we may need to pay tradeoffs when adding any new flag, and thus even for single target pseudo-classes, we may want to avoid adding support for those which don't really have good use cases. I'm not sure how other browsers implement |
A very common pattern is having a list of items (e.g. a gallery of products, or people, or a list of invoices etc) with every item being compact and showing little info until it's clicked, at which point all other items disappear and the item expands and displays all the data it contains in full size.
This can almost be done with CSS, by using
:target
to expand the item when the location hash matches its id. However, there is no way to make other items disappear in that case, so horrible hacks are usually employed, such as absolutely positioning the item to cover the list of other items.Similar issues (and hacks to solve them) exist with UI patterns such as tabs, where if no tab is selected, one wants to show the first tab.
Since
:focus-within
is feasible, I don't see why:target-within
wouldn't be, and it would immensely simplify such tasks. Thoughts?The text was updated successfully, but these errors were encountered: