html - Should html header tag only contain info common to all pages
问题描述
My header tag contains an image (logo) which is common to all pages and then page title which is different for each page. Suddenly occurred to me that perhaps only the image should be part of the header tag and title shoud go in the body tag ?
e.g
<header>
<img srcset="style/songkongheader.png 400w,style/songkongheader-medium.png 200w,style/songkongheader-small.png 100w," sizes="(max-width:800px) 200px,(max-width:600px) 100px,400px" class="mb-2">
<h2 class="subheading ui-corner-all" title="Undo Fixes">
<a style="text-decoration: none">
Undo Fixes
</a>
</h2>
</header>
Could someone please clarify
解决方案
您现在使用的方式<header>
似乎是完全有效和正确的。
根据MDN:
该
<header>
元素没有对内容进行分段,因此不会在大纲中引入新的部分。也就是说,一个<header>
元素通常旨在包含周围部分的标题(一个 h1-h6 元素),但这不是必需的。
他们提供了一个Page Header
例子(你的情况是 100%):
<header>
<h1>Main Page Title</h1>
<img src="mdn-logo-sm.png" alt="MDN logo">
</header>
推荐阅读
- css - python selenium,我如何使用 css 选择器分隔函数
- c - 如何精确地将浮点数转换为二进制
- dart - Flutter - Default value in dropdown
- vue.js - Vuejs 将值从 prop 或计算值绑定到 v-model
- ios - 转换[字节]?到 [字节]
- symfony - UniqueEntity 不检查更新
- javascript - 使用 HTTPS 在 Internet Explorer 11 的新选项卡中加载响应对象时未加载外部 JavaScript
- ruby-on-rails - Rake 无法在 Cygwin 上安装
- c++ - 从 Unity 启动的 c++ 控制台应用程序上不显示“Cout”消息
- angular - 不导入就无法访问功能模块