html 元素添加小标题_HTML标题和标题元素

html 元素添加小标题

The <head> element contains information about an HTML page, while the <body> contains elements that the user reads, views, and interacts with.

<head>元素包含有关 HTML页面的信息,而<body>包含用户阅读,查看并与之交互的元素。

There is only ever one <head> element on a page, and it is usually the first tag immediately inside the <html> element. Elements inside the <head> do not appear in the browser window under normal circumstances.

页面上只有一个<head>元素,通常是紧靠<html>元素内的第一个标签。 在正常情况下, <head>元素不会出现在浏览器窗口中。

标题 (title)

The <title> describes the primary purpose of the page. It exists nowhere else but inside the <head>. It should be the first thing you define in the document, after the basic structure of the page has been created.

<title>描述页面的主要目的 。 它只存在于<head>内部。 创建页面基本结构之后,这应该是您在文档中定义的第一件事。

<head>
    <title>Dudley Storey’s Home Page</title>
</head>

The <title> is used in several different contexts. It appears in:

<title>在几种不同的上下文中使用。 它出现在:

  1. The browser tab, next to the favicon

    图标旁边的浏览器选项卡

  2. The primary link text for search results

    搜索结果的主要链接文字

  3. Browser bookmarks

    浏览器书签
  4. Printed web pages

    印刷网页

Always make the title full, unique and descriptive. When making a web page for a company, include the company name and the subject of the page itself in the <title>:

始终使标题完整,独特且具有描述性 。 为公司制作网页时,请在<title>包括公司名称和页面本身的主题:

<title>Immortan Joe's Car Shop – Vehicles for Sale</title>

Alternatively, the subject of the page can go first:

另外,页面的主题可以排在第一位:

<title>Vehicles for Sale – Immortan Joe's Car Shop</title>

The separator between the page subject and the site name in the title doesn‘t matter: em-dashes () and pipes (|) are both common.

页面主题和标题中的站点名称之间的分隔符无关紧要:破折号( )和管道( | )都很常见。

If you don‘t use the site name in the title, at least provide a context: ”Dudley Storey‘s Hobbies” is much more informative than “My Hobbies”; “Products | Running Shoes” is better than “Products” or “Shoes”

如果您在标题中未使用网站名称,请至少提供一个上下文:“ Dudley Storey的兴趣爱好”比“我的兴趣爱好”提供更多信息; “产品| 跑鞋”优于“产品”或“鞋”

The title may also relate to the filename of the HTML page, but it doesn‘t have to.

标题也可能与HTML页面的文件名有关,但不是必须的。

The reason <title> should be created first is that most people are understandably eager to add content or a design, and tend to leave the <title> as an afterthought… or forget it entirely. By specifying it first, you set forth the purpose of the page.

应该首先创建<title>的原因是,可以理解,大多数人都渴望添加内容或设计,并且倾向于将<title>留作事后思考……或完全忘记它。 通过首先指定它,您可以阐明页面的用途

动动脑筋 (Use Your Head)

The <head> is used for many other purposes. At a minimum, it should include the following meta tags, written before the title:

<head>用于许多其他目的。 至少应包括以下meta标记 ,该标记位于标题之前

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    …
</head>

The meta tags, in order:

元标记,顺序为:

  1. Set character encoding for the document

    设置文档的字符编码

  2. Set correct scaling of the page on mobile devices

    在移动设备上设置页面的正确缩放

Optionally, if you are aiming to support Internet Explorer before version 11, include the following in the <head>:

(可选)如果您打算支持版本11之前的Internet Explorer,请在<head>添加以下内容:

<meta http-equiv="x-ua-compatible" content="ie=edge">

…which forces IE versions 9 and 10 to modern web standards (at least, the standards they were capable of when they were made).

…这迫使IE版本9和10达到现代Web标准(至少是它们在制作时能够使用的标准)。

头部元素的传统用法 (Traditional Uses of The Head Element)

Traditionally, the <head> has also contained links to stylesheets and JavaScript:

传统上, <head>也包含指向样式表JavaScript的链接:

<head>
…
    <link rel="stylesheet" href="styles.css">
    <script src="page.js"><script>
</head>

Additionally, or alternatively, it could include embedded stylesheets or scripts:

另外,或者替代地,它可以包括嵌入式样式表或脚本:

<head>
…
    <style>
        // CSS here
    </style>
    <script>
        // JavaScript here
    </script>
</head>

However, HTML5 does not require these elements to appear in the <head>. Today, they are frequently relocated lower down on the page, inside or below the <body>. This is done to reduce blocking.

但是,HTML5 不需要这些元素出现在<head> 。 如今,它们经常在页面的下方, <body>内或下方重新定位。 这样做是为了减少阻塞

头块 (Head-Block)

Since pages are read and interpreted by a browser from the top down, lengthy scripts or styles in the <head> can slow down or block page rendering. By moving these elements below the <body>, the page can, in principle, render faster.

由于浏览器会自上而下地读取和解释页面,因此<head>冗长的脚本或样式可能会减慢或阻止页面呈现。 通过移动下面这些元素<body>页面可以在原则上,呈现速度就越快。

For basic web pages, keeping styles in the <head> is still a good idea; placing scripts at the bottom of the page is a best practice.

对于基本网页,将样式保留在<head>中仍然是一个好主意。 最佳做法是在页面底部放置脚本。

In more advanced web development, the scripts and styles may be located both in the <head> and lower down on the page, with code that influences the look of the page “above the fold” - that is, the portion of the page that the user initially sees when it loads - left in the <head>, and the rest, affecting the remainder of the page, left lower down.

在更先进的网络开发中,脚本和样式可以在位于两者 <head>降低了网页上,与代码影响在网页“上面的折”的外观-即,页面的该部分用户最初在加载时会看到-留在<head> ,其余部分会影响页面的其余部分,并从左下方向下看。

A minimal <head> section would therefore consist of:

因此,最小的<head>部分将包括:

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Your Page Title Here</title>
</head>

Josh Buchea has an excellent list of everything that can go in the <head> section of an HTML document. It should be emphasized that there’s no requirement that you put everything in this list in the <head>; it simply provides all the possibilities.

Josh Buchea HTML文档<head>部分列出了非常不错的所有内容。 应该强调的是,不要求您将所有内容都放在此列表的<head> ; 它只是提供了所有可能性。

翻译自: https://thenewcode.com/11/The-HTML-head-and-title-Elements

html 元素添加小标题

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值