链接 PDF(带图标)的最佳方法是什么?

发布于 2024-08-23 21:29:03 字数 1412 浏览 9 评论 0原文

就语义、可访问性、可用性和 SEO 而言,在页面上链接 PDF(带图标)的首选方法是什么?

例如

  • ,这是 PDF 的名称“01ccc5.pdf” 但在 PDF 中,这是标题 PDF“如何在长 PDF 中搜索” 我应该使用 PDF 主题作为文件吗 名称如“How-to-search-in-long-PDF?”
  • 并且我想将 PDF 的链接显示为 页面上的 PDF 图标是什么 就可访问性而言的最佳方式 和可用性。
  • 我应该插入 pdf 图标作为 里面或者我应该用作CSS 背景?

哪种方法更好?这个

a{text-indent:-99999px}

<a href="How-to-search-in-long-pdf.pdf" title="PDF, 25KB, Opens in a new window">
How to search in long PDF 
<img src=pdf-icon.jpg" alt="How to search in long PDF" />
</a> 

或这个

  a{text-indent:-99999px;background:url(pdf-icon.jpg);width:32px:height:32px}

或这个方法 http://www.askthecssguy.com/2006/12/ shown_hyperlink_cues_with_cs_1.html

<a href="How-to-search-in-long-pdf.pdf" title="PDF, 25KB, Opens in a new window">
How to search in long PDF </a> 

我必须链接多个 PDF


注意:

PDF 的标题也将在 PDF 之前可用,但没有任何链接,

如下所示:

Title                                      PDF

How to search in long PDF                  PDF icon (with link of PDF)

How to search in long PDF                  PDF icon (with link of PDF)

How to search in long PDF                  PDF icon (with link of PDF)

What is preferred method to link PDF(with icon) on a page in terms of semantic, accessibility, usability and SEO?

for example

  • this is a name of PDF "01ccc5.pdf"
    but inside PDF this is the title of
    PDF "How to search in long PDF"
    Should i use PDF subject as a file
    name like "How-to-search-in-long-PDF?
  • and I want to show link of PDF as a
    PDF icon on the page, What is the
    best way in terms of accessibility
    and usability.
  • Should i insert pdf icon as a
    inside or i should use as a css
    background?

Which method is better? this

a{text-indent:-99999px}

<a href="How-to-search-in-long-pdf.pdf" title="PDF, 25KB, Opens in a new window">
How to search in long PDF 
<img src=pdf-icon.jpg" alt="How to search in long PDF" />
</a> 

or this

  a{text-indent:-99999px;background:url(pdf-icon.jpg);width:32px:height:32px}

or this method http://www.askthecssguy.com/2006/12/showing_hyperlink_cues_with_cs_1.html

<a href="How-to-search-in-long-pdf.pdf" title="PDF, 25KB, Opens in a new window">
How to search in long PDF </a> 

I have to link multiple PDF


Note:

Title of PDF is also will be available before PDF but without any link

like this:

Title                                      PDF

How to search in long PDF                  PDF icon (with link of PDF)

How to search in long PDF                  PDF icon (with link of PDF)

How to search in long PDF                  PDF icon (with link of PDF)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情深如许 2024-08-30 21:29:03

使用 CSS3 在每个链接中添加 pdf 或其他图标的简单方法:

1.图标通过背景图像 -> CSS 代码:

a[href$=".pdf"]
{
  background:url("your-pdf-image.png") no-repeat left;
  padding-left:25px;
}

2.从 FontAwesome 带来图标 -> CSS 代码:

a[href$=".pdf"]:before
{
  content:"\f1c1  ";
  font-family: fontawesome;
}

Easy way to bring pdf or other icon with each link using CSS3:

1. icon through background image -> CSS Code:

a[href$=".pdf"]
{
  background:url("your-pdf-image.png") no-repeat left;
  padding-left:25px;
}

2. bring icon from FontAwesome -> CSS Code:

a[href$=".pdf"]:before
{
  content:"\f1c1  ";
  font-family: fontawesome;
}
伴我心暖 2024-08-30 21:29:03

最后一个是最好的,因为所有内容都在 CSS 中。然而,它在 IE6 中不起作用——尽管我们都希望这个浏览器消失,但它仍然被广泛使用。

因此,我将使用第二个,带有一个特殊的类(例如a.pdf)。如果您有多个具有不同文件类型的链接,请使用 sprites

编辑:我刚刚明白你为什么使用负文本缩进。我不确定它是否能在背景下正常工作。在这种情况下,我可能会使用带有 alt 文本的 img,而 a 没有文本内容。我几乎总是喜欢使用文本和图像,尤其是下载链接。

The last one is the best since everything is in the CSS. However, it doesn't work in IE6- and as much as we would all like this browser to die, it is still well used.

So, I'd use the second one, with a special class (e.g. a.pdf). And if you have multiple links with different file types, use sprites.

Edit: I've just understood why you used a negative text-indent. I'm not sure it will work properly with a background. In that case, I'd probably use an img with an alt text and no text content for the a. I nearly always favor using a text and an image, especially for download links.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文