HTML is a powerful language for creating web pages, and while most developers are familiar with commonly used HTML attributes, there are several lesser-known attributes that can provide additional functionality and enhance the user experience.
1. The enterkeyhint Attribute for Virtual Keyboards
When designing web forms for mobile devices, it’s important to consider the virtual keyboards that users interact with. The enterkeyhint attribute is a global attribute that can be applied to form controls or elements with the contenteditable attribute set to true. It assists users by providing hints to the virtual keyboard about the intended action associated with the "Enter" key. This attribute accepts values such as enter, done, go, next, previous, search, and send, allowing you to customize the hint based on the specific context of your application.
<input type="text" enterkeyhint="done">
2. Attributes for Custom Ordered Lists
While working with ordered lists
- , you can utilize several lesser-known attributes to customize the behavior of the numbering. These attributes include:
The reversed attribute: It allows you to number the list items in reverse order, from high to low instead of the default low to high.
The start attribute: It defines the number from which the list should start.
The type attribute: It specifies whether to use numbers, letters, or Roman numerals for the list items.
The value attribute: It enables you to set a custom number for a specific list item.
<ol reversed> <li>List item...</li> <li>List item...</li> <li>List item...</li> </ol> <ol reversed start="20" type="1"> <li>Typee: A Peep at Polynesian Life (1846)</li> <li>Omoo: A Narrative of Adventures in the South Seas (1847)</li> <li>Mardi: and aVoyage Thither (1849)</li> <li>Redburn: His First Voyage (1849)</li> <li value="100">White-Jacket; or, The World in a Man-of-War (1850)</li> <li>Moby-Dick; or, The Whale (1851)</li> <li>Pierre; or, The Ambiguities (1852)</li> <li>Isle of the Cross (1853 unpublished, and now lost)</li> </ol>
3. The decoding Attribute for
Element
The decoding attribute allows you to provide a hint to the browser about how an image should be decoded. This attribute can be added to an element and accepts three values: sync, async, and auto.
sync: Decode the image synchronously, which is the default behavior.
async: Decode the image asynchronously to avoid delaying the presentation of other content.
auto: Let the browser use its default decoding method.
<img src="/static/imghwm/default1.png" data-src="/images/example.png" class="lazy" alt="esser-已知的 HTML 屬性可增強使用者體驗" decoding="async">
By specifying the appropriate decoding behavior, you can optimize the loading and rendering of images on your web page.
4. The loading Attribute for
Similar to lazy loading images, the loading attribute can be applied to
<iframe src="/page.html" width="300" height="250" loading="lazy"></iframe>
5. The crossorigin Attribute for Cross-Origin Resource Sharing (CORS)
When working with elements like ,
<img src="/static/imghwm/default1.png" data-src="https://example.com/image.jpg?x-oss-process=image/resize,p_40" class="lazy" crossorigin="anonymous" alt="esser-已知的 HTML 屬性可增強使用者體驗 Image">
The attribute accepts two values: anonymous and use-credentials. Setting it to anonymous indicates that the resource should be fetched without including user credentials, while use-credentials indicates that the user credentials should be included.
6. The disablepictureinpicture Attribute for
The disablepictureinpicture attribute can be applied to the
<video src="example.mp4" disablepictureinpicture controls></video>
7. The integrity Attribute for Scripts
To ensure that external scripts haven’t been tampered with, you can make use of the integrity attribute. This attribute allows you to provide a cryptographic hash value that the browser can use to verify the integrity of the script file before executing it.
<script src="script.js" integrity="sha256-Kx70Z9jzvYF0Eex8oO7w08=" crossorigin="anonymous"></script>
By including the integrity attribute with the appropriate hash value, you can add an extra layer of security to ensure the script's authenticity.
Conclusion
In this article, we have explored a collection of lesser-known HTML attributes that can enhance your web development projects. From improving user interactions to optimizing resource loading, these attributes provide valuable functionalities that may not be widely known or utilized.
如果您覺得這有幫助,請考慮訂閱_以獲取更多有關 Web 開發的有用文章和工具。感謝您的閱讀!
以上是esser-已知的 HTML 屬性可增強使用者體驗的詳細內容。更多資訊請關注PHP中文網其他相關文章!

JavaScript是現代Web開發的核心語言,因其多樣性和靈活性而廣泛應用。 1)前端開發:通過DOM操作和現代框架(如React、Vue.js、Angular)構建動態網頁和單頁面應用。 2)服務器端開發:Node.js利用非阻塞I/O模型處理高並發和實時應用。 3)移動和桌面應用開發:通過ReactNative和Electron實現跨平台開發,提高開發效率。

JavaScript的最新趨勢包括TypeScript的崛起、現代框架和庫的流行以及WebAssembly的應用。未來前景涵蓋更強大的類型系統、服務器端JavaScript的發展、人工智能和機器學習的擴展以及物聯網和邊緣計算的潛力。

JavaScript是現代Web開發的基石,它的主要功能包括事件驅動編程、動態內容生成和異步編程。 1)事件驅動編程允許網頁根據用戶操作動態變化。 2)動態內容生成使得頁面內容可以根據條件調整。 3)異步編程確保用戶界面不被阻塞。 JavaScript廣泛應用於網頁交互、單頁面應用和服務器端開發,極大地提升了用戶體驗和跨平台開發的靈活性。

Python更适合数据科学和机器学习,JavaScript更适合前端和全栈开发。1.Python以简洁语法和丰富库生态著称,适用于数据分析和Web开发。2.JavaScript是前端开发核心,Node.js支持服务器端编程,适用于全栈开发。

JavaScript不需要安裝,因為它已內置於現代瀏覽器中。你只需文本編輯器和瀏覽器即可開始使用。 1)在瀏覽器環境中,通過標籤嵌入HTML文件中運行。 2)在Node.js環境中,下載並安裝Node.js後,通過命令行運行JavaScript文件。

如何在Quartz中提前發送任務通知在使用Quartz定時器進行任務調度時,任務的執行時間是由cron表達式設定的。現�...

在JavaScript中如何獲取原型鏈上函數的參數在JavaScript編程中,理解和操作原型鏈上的函數參數是常見且重要的任�...

在微信小程序web-view中使用Vue.js動態style位移失效的原因分析在使用Vue.js...


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

Dreamweaver CS6
視覺化網頁開發工具