HTML tabindex 属性
htmlweb developmentfront end technology更新于 2024/5/21 18:52:17
HTML tabindex 属性定义 HTML 文档中元素的 Tab 键顺序。它是一个全局属性,这意味着它可以用于任何 HTML 元素。
语法
以下是语法 −
<tagname tabindex=”number”></tagname>
示例
让我们看一个 HTML tabindex 属性的示例 −
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
text-align: center;
}
p {
font-size: 1.2rem;
}
</style>
<body>
<h1>HTML tabindex Attribute</h1>
<p tabindex="5">I'm paragraph.</p>
<p tabindex="4">I'm paragraph.</p>
<p tabindex="3">I'm paragraph.</p>
<p tabindex="2">I'm paragraph.</p>
<p tabindex="1">I'm paragraph.</p>
<p>Now, try to navigate through paragraph using tab key</p>
</body>
</html>
输出

现在尝试使用 Tab 键浏览段落。


相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

