我可以在SVG元素中使用alt和title属性吗? [英] Can I use alt and title properties within SVG elements?

查看:1926
本文介绍了我可以在SVG元素中使用alt和title属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使我的内联SVG图像更易于谷歌搜索,您可以在svg元素中添加alt / title属性/属性,例如pathcircleline等?

To make my inline SVG image more searchable by google, can you add alt/title properties/attributes within svg elements such as "path" "circle" "line" etc?

我已经知道你可以在svg标签中使用标题标签,就像这样..

I already know that you can use a title tag within the "svg" tag, like this..

<svg>
<title>this is a title tag.</title>
</svg>

以下是我所说的一个例子。

Below is an example of what I am talking about.

<svg version="1.1" id="Layer_1">
    <style type="text/css">

    .st0{fill:none;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-miterlimit:10;}
</style>

<path class="st0" title="this is what I am talking about" d="M567,1136.2l37,10.9c13.3,3.9,27.2,3.1,39.9-2.4l0.6-0.3"/>

<line id="hi2" class="st5" alt="This is what I am Talking About" x1="72" y1="-169.7" x2="108" y2="-169.7"/>
</svg>


推荐答案

据我所知,替代文字不能是用于SVG。您使用< title> 代码是正确的,但您也可以添加< desc> 来添加更多内容信息。

As far as I am aware, alt text cannot be used on SVGs. You are right in using <title> tags, but you can also add in <desc> to add more information.

在这里看一下这个答案: https:// stackoverflow .com / a / 4756461/3909886 有关此问题的详细介绍。

Take a look at this answer here: https://stackoverflow.com/a/4756461/3909886 for a more detailed look into this issue.

这篇关于我可以在SVG元素中使用alt和title属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆