Skip to content

Question - why does font awesome use <title> element in svg sprites? #14595

@kpion

Description

@kpion

Toying with SVG Sprites with Font Awesome Free 5.7.1 here.

And I'm trying to understand why do we have the <title> in the SVG sprite files, like this one:

<symbol id="user" viewBox="0 0 448 512">
    <title id="user-title">User</title>
    <path d="M224 256c70.7 0 ......"></path>
</symbol>

When I use i in the recommended way:

<svg class = 'fa-svg-icon'>
    <use xlink:href="icons/font-awesome/sprites/solid.svg#user"></use>
</svg>

I see a tooltip "User" which is not what I want. If I wanted it, I would give it to the parent element.

Here is a test page: https://kpion.github.io/stuff/font-awesome-issue/

I do understand I can use the js version, or write my own js which will remove the <title> but I don't really want to, plus I would really love to hear an answer to why?

I mean, I do know this is w3c's recommendation and is about accessibility, but I have a feeling there is sort of misunderstanding here. Because my guess is that those RFC's are focused on complex svg documents built of many components (the 'use' part), and therefore the suggestion about titles and descriptions applies to the components (in the scenario, where we have many of them in a complex svg).

I can't really find a reason to believe it's about using SVG files as single (non-composite, or composed of only one def) images/icons on a website / app.

IMO, right now the situation, by analogy, is like the PNG creators were adding a <title> tooltip to the files and website creators could not remove / modify them.

I'm pretty sure I do miss something here, just don't know how to identify it o.O

Note that there is also aria-label which seems much much more desired in this context.

p.s.
Although this is a draft, it's pretty clear for me, that the authors focus on the 'components' when they talk about 'title' and 'description': https://w3c.github.io/writing-accessible-svg/accessible-svg.html - I mean the whole <use> thing. For example they say:

Authors should include a desc element for each graphical object defined in the defs that they reference with a use element.

I also asked on SO, without any spectacular success: https://stackoverflow.com/questions/54385153/how-to-get-rid-of-title-on-mouse-hover-on-font-awesome-svg-icon-using-svg-sprit

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions