CSS text truncation is very simple to implement and is very performant since we are not editing the HTML content of the text, only its render. While single-line text truncation is well supported in older browsers, multi-line text truncation is only supported on newer browsers.
The downside of this implementation is that the input HTML radio inputs are in the reverse order (from 5 to 1 rating value) because we need to select all the starts up to and including the checked input which is not possible to select with CSS. That's why we reverse the order and select inputs from the checked input to the first input.
This implementation is very flexible and can be easily customized.
This is a very flexible element because it's CSS logic can be used for both tooltips and dropdown menus, because they work in a similar way and both support the hover and click (touch) functionalities.
Something that can be considered an issue with this implementation is that due to it's
focus styles, the tooltip (dropdown) will remain open on click until the user clicks away from the element (element uses focus).
This a bit of a hacky implementation that relies entirely on the query string of the URL. Id in the URL needs to match the modal element that we need to open.
I've covered floating label inputs implementation in a separate article since this implementation is a bit more complex.
Recently, HTML got its native accordion (toggle) element with
The downside of using this implementation is that it relies on
input HTML element and it's logic resulting in extra HTML code needed, but also on the flip side, this results in a very accessible element.
As you can see, these CSS-only implementations rely on CSS selector logic like
Of course, there are many more CSS-only solutions out there, but I've found these ones most interesting. If you are using any other solutions, please do let me know in the comments.
Thank you for taking the time to read this post. If you've found this useful, please give it a ❤️ or 🦄, share and comment.