Home Web Front-end Front-end Q&A What are the attributes of html elements?

What are the attributes of html elements?

Dec 23, 2021 am 11:50 AM
html element attributes

html element attributes include: accesskey, class, contenteditable, contextmenu, "data-*", dir, draggable, dropzone, hidden, id, lang, spellcheck, style, etc.

What are the attributes of html elements?

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

What are attributes

Attributes can provide some additional information for HTML tags, or modify HTML tags. Attributes need to be added in the start tag, and the syntax format is:

attr="value"
Copy after login

attr represents the attribute name, and value represents the attribute value. Attribute values ​​must be surrounded by double quotes " " or single quotes ' '.

Note that although both double quotes and single quotes can surround attribute values, for the sake of standardization and professionalism, please use double quotes as much as possible.

A tag can have no attributes, or it can have one or more attributes.

There are many HTML attributes, which can be roughly divided into two categories:

  • Some attributes are applicable to most or all HTML tags. We call these attributes universal attributes;

  • Some attributes are only applicable to one or a few specific HTML tags. We call these attributes special attributes.

Common properties (global properties)

Properties Description
accesskey Sets the keyboard shortcut for accessing an element.
class Specifies the class name of the element
contenteditable Specifies whether it can be edited The content of the element.
contextmenu Specifies the context menu of an element. When the user right-clicks the element, a context menu appears
data-* Used to store custom data for the page
dir Set the text direction of the content in the element.
draggable Specify whether an element can be dragged
dropzone Specify whether to drag data Copy, move, or link, or delete
hidden The hidden attribute specifies that the element is hidden.
id Specifies the unique id of the element
lang Set the language code of the content in the element .
spellcheck Detect whether the element is spelled incorrectly
style Specify the inline style of the element (inline style)
tabindex Set the tab key control order of elements.
title Specifies additional information for the element (can be displayed in a tooltip)
translate Specify whether the value of an element needs to be translated when the page is loaded

Special properties

The following will introduce to you the properties of several commonly used tags

Properties of tags

Attributes Value Description
charset char_encoding HTML5 Not supported. Specifies the character encoding of the target URL.
coords coordinates HTML5 Not supported. Specifies the coordinates of the link.
download filename Specify download link
href URL Specifies the target URL of the link.
hreflang language_code Specifies the base language of the target URL. Only used if the href attribute is present.
media media_query Specifies the media type of the target URL. Default value: all. Only used if the href attribute is present.
name section_name HTML5 Not supported. Specifies the name of the anchor.
rel alternate
author
bookmark
help
license
next
nofollow
noreferrer
prefetch
prev
search
tag
Specifies the relationship between the current document and the target URL. Only used if the href attribute is present.
rev text HTML5 Not supported. Specifies the relationship between the target URL and the current document.
shape default
rect
circle
poly
HTML5 is not supported. Specifies the shape of the link.
target _blank
_parent
_self
_top
framename

specifies where to open the target URL. Only used if the href attribute is present.

  • _blank: New window opens.
  • _parent: Open the link in the parent window.
  • _self: Default, jump to the current page.
  • _top: Open the link in the current form and replace the entire current form (frame page).
type MIME_type Specifies the MIME type of the target URL. Only used if the href attribute is present.
Note: MIME = Multipurpose Internet Mail Extensions.

tag attributes

Attributes Value Description
accept MIME_type HTML5 Not supported. Specifies the type of file received by the server. (Files are submitted via file upload)
accept-charset character_set Specifies the form data that the server can process character set.
action URL Specifies where to send form data when the form is submitted.
autocomplete on
off
Specifies whether to enable the autocomplete function of the form.
enctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how to encode form data before sending it to the server. (Applicable to method="post")
method get
post
Specifies the HTTP method used to send form data .
name text Specifies the name of the form.
novalidate novalidate If this attribute is used, no validation will be performed when submitting the form.
target _blank
_self
_parent
_top
Specifies where to open the action URL.

Tag attributes

Attributes Value Description
manifest URL Define a URL on which the description Document cache information.
xmlns http://www.w3.org/1999/xhtml HTML is not supported. Only XHTML supported. Specify the XML namespace attribute (use this attribute if you need your content to conform to XHTML.).

Attribute Value Description
disabled disabled Specifies that this option should be disabled on first load.
label text Defines the label used when is used.
selected selected Specifies that the option appears selected (when first displayed in the list).
value text Defines the option value sent to the server.

. . . .

Related recommendations: "html video tutorial"

The above is the detailed content of What are the attributes of html elements?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles