Dynamically generated HTML link icons .. with CSS-only!

Mate Marschalko
6 min readMar 31, 2022

Yes we could add icons to links by simply assigning classes or IDs. But could we dynamically add icons by analysing file names, links or the existence of certain attributes?

Yes we can! All with the CSS attribute selector.

CSS attribute selectors

--

--

Mate Marschalko

Senior Creative Developer, Generative AI, Electronics with over 15 years experience | JavaScript, HTML, CSS