Hey guys,
Small accessibility / SEO tweak request…
When using an SVG as the theme logo, it doesn’t output any ALT text, despite having ALT text set within the media library.
Would be great if this could be fixed, Lighthouse is always flagging it as an Accessibility issue.
Thanks for your work,
Regards
Tim
Hey Tim,
Thanks for contacting us!
SVG elements does not have an ALT attribute – https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute. Could you use Title or Desc tags inside SVG element instead?
Best regards,
Yigit
but if you like to force : open that svg file before uploading with a (good) text editor and insert on the svg tag yourself an alt attribute.
if you like to have on the a tag ( this is not an attribute allowed for a-tag ) a title or alt:
( see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a )
function custom_logo_attriubtes(){
?>
<script>
(function($){
$('.logo > a').attr({ title:"here comes a new title Attribute", alt:"Your new Alt Attribute" });
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'custom_logo_attriubtes');
Ah ok, thanks for the info, much appreciated.
Hi,
Thanks for your help @Guenni007! :)
Let us know if you have any other questions and enjoy the rest of your day, Tim!
Best regards,
Yigit