Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Can the html5 attribute value ignore quotation marks?

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "html5 attribute value can ignore quotation marks", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "html5 attribute value can ignore quotation marks" bar!

The value of the html5 attribute can ignore quotation marks. In html5, the quotation marks on both sides of the attribute value in the tag are optional, and if the attribute value does not contain spaces or any special symbols such as "", "'", "`", "=", "", and so on, it can be kept without quotation marks.

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

Html5 can use single quotation marks, double quotation marks, and no quotation marks, and the quotation marks around the attribute values in the tag are optional. But it's customary to write.

W3C working draft (13 January 2011):

The property value can be kept without quotation marks if it does not contain spaces or any special symbols such as,', `, =, etc.

Detailed explanation of the rule of whether attribute values are in quotation marks or not in HTML

Description:

When the attribute value is a word or a whole string of characters (without spaces in the middle): you can leave it without quotation marks

When the attribute value is multiple words or a whole string of characters (with spaces in the middle): quotation marks are required

Note: the above are the teacher's original words, personal experiments found that whether to add quotation marks depends on whether there is a space in the value, there is a space plus quotation marks, there is no need to add [but for good programming habits, it is recommended to add quotation marks in both cases]

Experiment:

Case 1: material name (there is no space in the name):

Code ① (value in quotation marks):

logo

Normal display

Code ② (value without quotation marks):

logo

Normal display

Case 2: material name (with a space in the name):

Code ① (value in quotation marks):

logo

Normal display

Code ② (value without quotation marks):

logo

Picture not found

Summary: it can be seen that there are spaces in the value, and the value must be enclosed in quotation marks. If there is no space in the value, you can add it or not.

Extended knowledge: some details of html5 that are easy to ignore

In html5, spaces and slashes at the end of an empty element are negligible.

The quotation marks on both sides of the attribute value in the tag are optional. But it's customary to write.

The numeric value of the property does not need to be entered in units, just the value itself. Such as height and width in the label.

Some attributes in the tag accept only predefined values (also known as enumerated values). Be sure to write enumerated values in lowercase letters. Such as type of input. Some properties can be any value, such as the Value of input.

There is also a special Boolean attribute value in the tag. This property value is optional and, if present, is represented as true. If you have to fill in the value, fill in yourself. Such as hidden= "hidden".

Html naming conventions: it's best to use all lowercase letters, use-(dash) to separate words, and extension .html (although you can also use .htm for html pages).

The alt attribute in the tag img is used to display the text if the picture is not successfully loaded or accessed only through a text-only browser (rarely), and the screen reader will read the text aloud (accessible).

The title tag must be inside the head tag and after the character-encoded meta tag.

Thank you for your reading, the above is the "html5 attribute value can ignore quotation marks" content, after the study of this article, I believe you can ignore quotation marks on the html5 attribute value of this problem has a deeper understanding, the specific use of the need for you to practice verification. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report