Skip to content

Comments

Fix tooltip on <img> and other replaced elements#86

Open
laurentbardin wants to merge 1 commit intoknadh:masterfrom
laurentbardin:fix-tooltip-on-replaced-elements
Open

Fix tooltip on <img> and other replaced elements#86
laurentbardin wants to merge 1 commit intoknadh:masterfrom
laurentbardin:fix-tooltip-on-replaced-elements

Conversation

@laurentbardin
Copy link

@laurentbardin laurentbardin commented Feb 19, 2026

Using ::before and ::after to manage tooltips can't work on replaced elements, the most common of those being <img>.

We should skip those elements in order to preserve their title attribute so that the default browser behaviour still works and the tooltip text can be displayed.

Alternatively, we could still add the data-tooltip or aria-label attribute (or both), and simply skip the removal of the title attribute.

@laurentbardin laurentbardin changed the title Fix tooltip on replaced elements Fix tooltip on <img> and other replaced elements Feb 20, 2026
Tooltips use `::before` and `::after`, which cannot work on replaced
elements, the most common of which is `<img>`. We skip those elements
when initialising the tooltips so that their `title` attribute is not
removed and it can still be displayed by the browser when hovering over
them.
@laurentbardin laurentbardin force-pushed the fix-tooltip-on-replaced-elements branch from 791869d to 94e893b Compare February 23, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant