如何在 HTML 关键字中使用 unicode 字符?

发布于 2024-12-22 09:04:57 字数 384 浏览 1 评论 0原文

HTML 文档的元部分可以包含关键字部分。

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="description" content="under construction" />
        <meta name="keywords"
          content="..." />

可以在本节中使用 unicode 字符(即 \u00B0)吗?如果是的话怎么办?

The meta section of HTML documents can contain a keyword section.

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="description" content="under construction" />
        <meta name="keywords"
          content="..." />

Can one use unicode characters in this section (i.e., \u00B0)? If yes how?

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

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

发布评论

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

评论(2

欢你一世 2024-12-29 09:04:57

您放入 HTML 文档中的所有字符,无论是在属性值中还是在其他位置,都作为 Unicode 字符。如果您的文档的字符编码是 UTF-8,如您的示例所示(但最好是 UTF-8 编码!),您可以直接在那里输入任何字符,例如度数符号 (°)。如何执行此操作取决于您的创作环境。您也可以使用字符引用(如 °),或者对于某些字符,使用实体引用(如 °)。

但 \u00B0 不是 HTML 表示法。它只是六个字符的序列。它在 JavaScript 中具有特殊含义,但在 HTML 中则没有。相应的 HTML 表示法是 °

搜索引擎可能会忽略特殊字符,例如关键字中的学位符号。但也不一定;据观察,谷歌在某些特殊情况下对它们很敏感。 (目前看来,不适用于学位标志。)

标签中,如果搜索引擎在构建页面时使用其内容,则特殊字符可能是相关的搜索结果列表的描述。这样的事情仍然会发生,尽管比以前少了。

All the characters you put into an HTML document, whether in attribute values or elsewhere, as Unicode characters. If the character encoding of your document is UTF-8, as your example declares (but it had better be UTF-8 encoded then!), you can enter any characters, such as the degree sign (°), directly there. How you do that depends on your authoring environment. You can alternatively use a character reference (like °) or, for some characters, an entity reference (like °).

But \u00B0 is not an HTML notation. It just a sequence of six characters. It has a special meaning in JavaScript, but not in HTML. The corresponding HTML notation is °.

Search engines will probably ignore special characters like the degree sign in keywords. But not necessarily; Google has been observed to be sensitive to them in some special situations. (Not for the degree sign at the moment, it seems.)

In <meta name=description ...> tags, special characters may be relevant if search engines use their content when constructing the page description for search result lists. Such things still happen, though less frequently than they used to.

﹎☆浅夏丿初晴 2024-12-29 09:04:57

由于使用 Unicode 作为其正文内容的非英语网站也会使用 Unicode 作为其元数据,因此可以合理地假设处理 HTML 元数据的重要工具将能够以 UTF-8 处理这种情况。

另请记住(至少在历史上)keywords 元标记旨在包含人们可能搜索的术语。您的示例 \00B0 是度数符号;在这种情况下,人们似乎更有可能搜索单词而不是符号°。由于关键字元数据的广泛滥用,许多搜索引擎(包括 Google)在搜索排名时忽略它们。

因此,总而言之,我认为使用 Unicode 关键字元数据是安全的。但它可能不会提高您网站对这些字词的搜索排名。

Because non-English websites that use Unicode for their body content will also use Unicode for their metadata, it is reasonable to assume that the important tools that process HTML metadata will be able to cope with this in UTF-8.

Also bear in mind that (at least historically) the keywords meta tag was meant to contain terms that people might search for. Your example \00B0 is the degrees sign; in this case it seems more likely people will search for the word degrees than for the symbol °. Because of wide-scale abuse of keyword metadata, many search engines (including Google) ignore them for search ranking.

So, in summary, I think it is safe to use Unicode keyword metadata. But it probably won't improve your site's search ranking for those terms.

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