http-equiv 属性定义了一个编译指示指令

实践:

1、

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
 
 

https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/meta#attr-http-equiv

http-equiv属性定义了一个编译指示指令。这个属性叫做 http-equiv(alent) 是因为所有允许的值都是特定 HTTP 头部的名称,如下:

  • content-security-policy
    它允许页面作者定义当前页的内容策略。 内容策略主要指定允许的服务器源和脚本端点,这有助于防止跨站点脚本攻击。
  • content-type
    如果使用这个属性,其值必须是"text/html; charset=utf-8"。注意:该属性只能用于 MIME type 为 text/html 的文档,不能用于 MIME 类型为 XML 的文档。
  • default-style

    设置默认 CSS 样式表组的名称。

  • x-ua-compatible
    如果指定,则 content 属性必须具有值 "IE=edge"。用户代理必须忽略此指示。

  • refresh
    这个属性指定:
    • 如果 content 只包含一个正整数,则为重新载入页面的时间间隔 (秒);
    • 如果 content 包含一个正整数,并且后面跟着字符串 ';url=' 和一个合法的 URL,则是重定向到指定链接的时间间隔 (秒)
可访问性相关考虑

设置了 refresh 值的页面可能有时间间隔太短的风险。使用诸如屏幕朗读这样的辅助技术来浏览网页的人可能会由于自动跳转而来不及读完或理解网页的内容。这样不经提示而突然进行的页面刷新也可能会让有视力障碍的人群感到迷惑。

 

http-equiv

Defines a pragma directive. The attribute is named http-equiv(alent) because all the allowed values are names of particular HTTP headers:

  • content-security-policy Allows page authors to define a content policy for the current page. Content policies mostly specify allowed server origins and script endpoints which help guard against cross-site scripting attacks.
  • content-type Declares the MIME type and character encoding of the document. If specified, the content attribute must have the value "text/html; charset=utf-8". This is equivalent to a <meta> element with the charset attribute specified, and carries the same restriction on placement within the document. Note: Can only be used in documents served with a text/html — not in documents served with an XML MIME type.
  • default-style Sets the name of the default CSS style sheet set.
  • x-ua-compatible If specified, the content attribute must have the value "IE=edge". User agents are required to ignore this pragma.
  • refresh This instruction specifies:
    • The number of seconds until the page should be reloaded - only if the contentattribute contains a non-negative integer.
    • The number of seconds until the page should redirect to another - only if the contentattribute contains a non-negative integer followed by the string ';url=', and a valid URL.
    ACCESSIBILITY CONCERNS
    Pages set with a refresh value run the risk of having the time interval being too short. People navigating with the aid of assistive technology such as a screen reader may be unable to read through and understand the page's content before being automatically redirected. The abrupt, unannounced updating of the page content may also be disorienting for people experiencing low vision conditions.

 

posted @ 2022-04-06 16:38  papering  阅读(264)  评论(0编辑  收藏  举报