|
|
|
|
|
by chrismorgan
1633 days ago
|
|
:target has been a possibility for many, many years, but is a poor choice for this sort of thing because it’s rather fragile (other things touch the fragment too) and messes with history. The better hack that has been long available is invisible checkboxes, :checked and a sibling selector. That’s almost certainly what “you could fake it with CSS too” was describing back then. But the proper solution now would be <details>. As an example of this, many dropdowns on GitHub work without JavaScript, by using <details>. I would note that with all of these alternatives, you tend to want a little JavaScript to enhance the functionality, e.g. manage ARIA states and focus. |
|