
Accessible and SEO friendly SVGs
Learn how to optimize your SVGs for better search engine visibility and ensure they are accessible to all users.
Making SVGs accessible is important to ensure that all users, including those with visual impairments, can access and understand the content of svg images. While accessibility primarily benefits users with disabilities, it can also indirectly contribute to SEO through improved user engagement and the presence of indexable text within inline SVGs.
What actually SVG is?
An SVG is not an image. It is a graphics-document and stands for Scalable Vector Graphics.
It is an XML-based vector image format used for defining two-dimensional graphics. SVG files are web-friendly and have the ability to scale up to any resolution without losing quality. This makes them ideal for web design, logos, and complex online graphics.
One of the primary advantages of SVG is that it can be created and changed using any text editor. SVG images can be searched, indexed, scripted, and compressed. They can be printed in great quality at any resolution and have zoom capabilities. Furthermore, when zoomed or resized, SVG graphics retain their original quality.
It is worth mentioning that SVGs are inherently scalable, meaning they can be zoomed in or out without losing any detail. This feature is particularly beneficial for users with visual impairments who might need to increase the size of the images on a webpage. The high-quality, sharp images ensure that even larger sizes remain clear and readable.
SVGs, unlike images, can include structured child elements such as animation elements (e.g., <animate>), basic shapes (e.g., <circle>), container elements (e.g., <a>), descriptive elements (e.g., <desc>, <title>), filter primitive elements (e.g., <feBlend>), text content elements (e.g., <text>), and more.
SVG and Accessibility
Browser and screen reader need to talk to each other. The screen reader needs to understand what the browser is communicating. And this, in turn, translates into what is presented to the screen reader user.
SVG is a vector image. However, what is rendered by the browser is not the same as what is presented to assistive technologies, like screen readers.
Here is the flow of how the browser, screen reader, and user communicate.

How do assistive technologies understand the content?
Semantic HTML is a way of writing HTML code that uses elements to describe the meaning and structure of the content. Examples of semantic elements include <form>, <table>, and <article>. On the other hand, non-semantic elements like <div> and <span> tell nothing about their content.
The difference between semantic and non-semantic HTML is that semantic HTML uses elements that describe the meaning and structure of the content, while non-semantic HTML uses elements that only define how the content looks.
By default, many semantic elements in HTML have a role. For example, <input type="radio"> has the radio role. Non-semantic elements in HTML do not have a role. For example, <div> and <span> without added semantics return null.
Native HTML elements and features may not provide sufficient description and behavior. HTML can be enhanced by using additional attributes and technologies that provide more information and functionality to the elements. The role attribute and aria-* attributes can provide a different semantics.
Let’s say you want to provide some notifications to the screen reader user. You could use <div role="status"></div> and screen readers will automatically announce the updated content.
Basically, ARIA supplements HTML, allowing interactions and widgets commonly used in applications to be passed to assistive technologies when there is not otherwise a mechanism natively available.
ARIA stands for Accessible Rich Internet Applications and is a technical specification published by the World Wide Web Consortium (W3C), an international community that develops web standards.
Accessible Rich Internet Applications (WAI-ARIA) 1.3, W3C First Public Working Draft, is open for review and might be a good source of what’s incoming new.
How do assistive technologies understand SVG?
Now that we know how the browser defines the meaning of individual elements, let’s take a closer look at the SVG element.
An SVG should have an implicit WAI-ARIA role="graphics-document".
The role="graphics-document" is an ARIA attribute that specifies that the element is a graphical document, which is distinct from other documents in that the visual layout of the content has semantic meaning. This role is appropriate for labelled diagrams and schematics, and it helps assistive technologies understand the web page better. The role="graphics-document" is a subclass of the generic document role.
However, this is not consistently exposed by the browsers. See what some browsers are actually exposing to the screen reader.
- Chromium-based browsers (e.g., Brave, Chrome, Opera, Edge) expose:
role="image". - Safari expose:
No matching ARIA role. - Firefox expose:
role="graphics-document".
What does that mean?
This means that the same screen reader receives completely different information from different browsers. Screen reader users might be confused by what’s being presented to them.
Robust solution: for most standalone SVG images (icons, illustrations, logos), explicitly add role="img" to force a consistent image role across all browsers. Be cautious with role="graphics-document" as it may cause some screen readers to enter browse or document reading mode, which is often not desired for a simple image.
Example 1: SVG icon and text
An example of an icon and text.
<a href="https://www.sitelint.com/contact/" rel="noopener" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 52.917 52.917"
aria-hidden="true" focusable="false">
[...]
</svg>
Contact us
</a>Here the icon is decorative because we have a text equivalent. The SVG is hidden from assistive technologies using aria-hidden="true". The focusable="false" is a legacy fix for older Internet Explorer and is not required for modern browsers.
Example 2: SVG icon only
An example of an icon only could be achieved in at least two ways.
<a href="https://www.sitelint.com/contact/" rel="noopener" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 52.917 52.917"
role="img" focusable="false" aria-labelledby="svgTitle">
<title id="svgTitle">Contact Us</title>
[...]
</svg>
</a><a href="https://www.sitelint.com/contact/" rel="noopener" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 52.917 52.917"
aria-hidden="true" focusable="false">
[...]
</svg>
<span class="visually-hidden">Contact us</span>
</a>Here the icon is decorative because we have a text equivalent. The SVG is hidden from assistive technologies using aria-hidden="true". A caution: if the SVG contained interactive elements (like clickable paths), those would also be hidden from assistive technology. This technique only works when the SVG is purely decorative.
You may notice also focusable="false". Read more about focusable=”false” from our rule accessible-svg
. Note that this is a legacy attribute for older Internet Explorer.
Example 3: SVG that should be treated as an image
<a href="https://www.sitelint.com/contact/" rel="noopener" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 52.917 52.917"
role="img" focusable="false" aria-labelledby="svgTitle">
<title id="svgTitle">Contact Us</title>
[...]
</svg>
</a>Example 4: SVG with complex data that requires a detailed description
Complex graphics require a detailed description. A good example are charts. We’ll use here <title> and <desc> HTML elements.
The <title> and <desc> elements are used to provide text alternatives for SVG content. Each container or graphics element within an SVG image can have one (or more) title and desc elements.
- The
<title>element provides a short human-readable name for the element that contains it. At least onetitleshould be provided for every SVG image. - The
<desc>element provides a longer human-readable description of the element that contains it. A description should be provided for complex SVG content, or where the SVG fulfils a particular function or purpose.
Note on aria-labelledby with both title and desc: using aria-labelledby="svgTitle svgDescription" will concatenate the text (title then description) without pause. For very long descriptions, consider using aria-describedby="svgDescription" instead, or link to an off-screen detailed explanation.
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="216.495" viewBox="0 0 79.375 57.281" aria-labelledby="svgTitle" aria-describedby="svgDescription">
<title id="svgTitle">Discovered dinosaurs over the last 4 years</title>
<desc id="svgDescription">2023 year: 46 species. 2022 year: 38 species. 2021 year: 30 species. 2020 year: 20 species.</desc>
[...]
</svg>Example 5: SVG image referenced in the src attribute of the img tag
Using SVG in an <img> tag is a straightforward way to include SVG images in your HTML document. The SVG image is referenced in the src attribute of the <img> tag.
Here’s an example:
<img src="example.svg" alt="Description of the image">However, there are a few things to note:
- When you add an SVG image using the
<img>tag without specifying the size, it assumes the size of the original SVG file. To change the original size, you have to specify thewidthandheightwith CSS. It is recommended to setwidthandheightfor the<img>tag so it looks as desired when CSS is not available. - Even though you can change the size of SVG images added via the
<img>tag, there are still some restrictions if you want to make major style changes to the SVG image. - The benefit of using
<img>is the ability to take advantage of the browser’s cache. The SVG can be loaded once and remain in the user’s browser cache, unlike inline SVGs which are part of the HTML and re-downloaded every time the HTML page is fetched.
SVG and Search Engine Optimization (SEO)
Despite appearances, you might believe that SVG has no effect on SEO. But it does, though the impact depends heavily on how you implement it.
Hyperlinks and SEO
One advantage of SVG images is that they can contain hyperlinks to other documents using SVG href attribute (xlink:href is deprecated). This is important for SEO strategies because search engines understand the importance of links for users and reward useful link structures on a website.
Page load times
SVG images are often smaller in file size compared to other image types. This can improve page load times, which indirectly benefits SEO. Faster loading pages tend to have better user experience and can positively impact search engine rankings.
To make SVG even more optimized you can also try removing unnecessary code such as comments, whitespace, metadata, and default values that can increase the file size and loading time of the SVG icon. Tools like SVGOMG can automate this process. Additionally, CSS or JavaScript can be used to style, animate, or interact with the SVG icon instead of embedding styles or scripts in the code, making it more modular, maintainable, and responsive.
Additionally, we recommend using a caching strategy. SVGs loaded via <img src="..."> are cached like any external image. Inline SVGs (<svg> directly in HTML) cannot be cached separately from the HTML document and are re-downloaded each time the HTML page is fetched.
Indexing in image search engine
Many search engines, like Google, Bing, Brave, Yandex, have special tools specifically designed for image searches. An image search engine works by analyzing the content of an image, such as its metadata, color distribution, and shape, to find relevant results based on the search criteria.
There are two main techniques used in image search:
- Search by metadata: This method compares the metadata associated with the image, such as the title, alternative description, format, and color, with a set of images sorted by relevance.
- Image query by example: This technique uses the content, shape, texture, and color of the image to compare it with other images in a database and then delivers the approximate match.
These search engines can be used to find images based on keywords, a picture, or a web link to a picture. Reverse image search is a feature that allows users to search for images using an image instead of keywords. This can be useful for various purposes, such as finding the original source or creator of an image, or checking if an image can be posted on a website.
Be careful with embedding SVG in HTML
Embedding SVG in HTML may not always be beneficial. The embedding of hundreds of icons is particularly overused, which causes the HTML to grow unnecessarily, and this also adds extra work to the browser when querying the DOM.
Not to mention the fact that we don’t use all the icons, but only a few.
Additionally, inline SVG is not cached separately, so each time the HTML is downloaded, all inline SVG code is downloaded again. You can observe this in the browser developer tools.
Does using the img tag have a greater impact on search engine optimization (SEO) than using the svg tag?
Both img and svg tags can be optimized for SEO, but they have different strengths. The key difference: text inside an inline <svg> element is indexable by search engines. Text inside an SVG loaded via <img src="..."> is not. Therefore, for text-heavy graphics (like charts with data labels), inline SVG has a crawlability advantage.
SVG advantages
- Better accessibility:
svgimages can be more accessible to screen readers and other assistive technologies, as the XML-based structure provides a clear representation of the visual elements. - Indexable text (inline only): text inside an inline
<svg>can be read by search engines, which is not possible with raster images or SVGs loaded via<img>.
Img advantages
- Wider support for raster formats: JPEG, PNG, and WebP are universally supported, though SVG is now supported in all modern browsers.
- Separate caching: external SVG files loaded via
<img>benefit from browser caching independently of the HTML.
While both approaches can positively impact SEO when properly optimized (with descriptive file names, appropriate dimensions, and accessible text), the best choice depends on your specific use case. For complex illustrations with text labels, inline SVG offers indexable content. For decorative icons or images where caching is a priority, external SVG via <img> is often better.
Summary
When an SVG is made accessible, it means that it is designed in a way that users with disabilities, such as visually impaired users who rely on screen readers, can access and understand the content. This involves adding alternative text descriptions, semantic roles, and other accessibility features to the SVG.
Making SVG accessible can indirectly contribute to better SEO by improving the overall user experience, which is a factor that search engines take into account when ranking websites. Additionally, providing alternative text descriptions for the SVG can also help search engines understand the content of the SVG and potentially improve its visibility in search results.
SVG images are scalable, look good on any device, and have no pixel limitation. They are text-based, which means they have smaller file sizes, which can boost loading times significantly and improve the performance of websites.
SVG does not gain automatic special benefits over other image formats, but they are often smaller than their raster counterparts, improving page load times, which benefits SEO indirectly. The choice between inline SVG and external SVG via <img> should be guided by whether you need indexable text and caching behavior.
Need help with digital accessibility?
- Audit and debug pages with reports in a user-friendly format directly from the browser.
- Install when you can't use browser extension.
- Audit fully rendered pages, including themes and plugins.
- Effortlessly audit every page automatically. Integrate a code snippet and manage multiple sites from a central dashboard.
Comments