html属性和css属性_HTML角色属性介绍

html属性和css属性

The role attribute describes the role of an element in programs that can make use of it, such as screen readers or magnifiers.

role属性描述了元素在可以使用它的程序中的角色,例如屏幕阅读器或放大镜。

Usage Example:

用法示例:

<a href="#" role="button">Button Link</a>

Screen Readers will read this element as “button” instead of “link”.

屏幕阅读器会将这个元素读为“按钮”,而不是“链接”。

There are four categories of roles:

角色分为四类:

  • Abstract Roles

    抽象角色
  • Widget Roles

    小部件角色
  • Document Structure Roles

    文件结构角色
  • Landmark Roles

    地标角色

有关HTML属性的更多信息: (More info about HTML attributes:)

<script src> attribute

<script src>属性

<a href> attribute

<a href>属性

<a target> attribute

<目标>属性

<body background> attribute

<body background>属性

<p align> attribute

<p align>属性

<img src> attribute

<img src>属性

<font> attribute

<font>属性

有关HTML属性的更多信息 (More info about HTML attributes)

HTML elements can have attributes, which contain additional information about the element.

HTML元素可以具有属性,其中包含有关该元素的其他信息。

HTML attributes generally come in name-value pairs, and always go in the opening tag of an element. The attribute name says what type of information you’re providing about the element, and the attribute value is the actual information.

HTML属性通常以名称/值对的形式出现,并且总是放在元素的开始标记中。 属性名称说明您要提供的有关元素的信息类型,而属性值是实际信息。

For example, an anchor (<a>) element in an HTML document creates links to other pages, or other parts of the page. You use the href attribute in the opening <a> tag to tell the browser where the link sends a user.

例如,HTML文档中的锚点( <a> )元素创建到其他页面或页面其他部分的链接。 您可以在开始的<a>标记中使用href属性,以告诉浏览器该链接将用户发送到何处。

Here’s an example of a link that sends users to freeCodeCamp’s home page:

这是将用户发送到freeCodeCamp主页的链接的示例:

<a href="www.freecodecamp.org">Click here to go to freeCodeCamp!</a>

Notice that the attribute name (href) and value (“www.freeCodeCamp.org”) are separated with an equals sign, and quotes surround the value.

请注意,属性名称( href )和值(“ www.freeCodeCamp.org”)用等号分隔,并用引号引起来。

There are many different HTML attributes, but most of them only work on certain HTML elements. For example, the href attribute won’t work if it’s placed in an opening <h1> tag.

HTML有许多不同的属性,但是大多数属性仅适用于某些HTML元素。 例如,如果将href属性放在开头的<h1>标记中,则该属性将不起作用。

In the example above, the value supplied to the href attribute could be any valid link. However, some attributes only have a set of valid options you can use, or values need to be in a specific format. The lang attribute tells the browser the default language of the contents in an HTML element. The values for the lang attribute should use standard language or country codes, such as en for English, or it for Italian.

在上面的示例中,提供给href属性的值可以是任何有效链接。 但是,某些属性只有一组可以使用的有效选项,或者值必须采用特定格式。 lang属性告诉浏览器HTML元素中内容的默认语言。 对于值lang属性应当使用规范的语言或国家代码,如en英语,或者it意大利。

布尔属性 (Boolean Attributes)

Some HTML attributes don’t need a value because they only have one option. These are called Boolean attributes. The presence of the attribute in a tag will apply it to that HTML element. However, it’s okay to write out the attribute name and set it equal to the one option of the value. In this case, the value is usually the same as the attribute name.

一些HTML属性不需要值,因为它们只有一个选项。 这些称为布尔属性。 标签中属性的存在会将其应用于该HTML元素。 但是,可以写出属性名称并将其设置为等于值的一个选项。 在这种情况下,该值通常与属性名称相同。

For example, the <input> element in a form can have a required attribute. This requires users to fill out that item before they can submit the form.

例如,表单中的<input>元素可以具有required属性。 这就要求用户填写该项目,然后才能提交表单。

Here are examples that do the same thing:

以下是执行相同操作的示例:

<input type="text" required >
<input type="text" required="required" >

翻译自: https://www.freecodecamp.org/news/html-role-attribute/

html属性和css属性

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值