定义“自定义"商品是否是不好的做法? HTML标签 [英] Is it bad practice to define a "custom" HTML tag
问题描述
我在代码(<include>
)中使用了自定义HTML标记.这是不好的做法吗?如果是的话,应该用什么代替.
I am using a custom HTML tag in my code (<include>
). Is this bad practice and if so what should it be replaced with.
在我看来,它通过在标签名称而不是<div class="include">
中使用含义来增加代码的可读性.
It seems to me that it adds readability to the code by having the meaning in the tag name instead of a <div class="include">
.
推荐答案
如今,创建自定义HTML标记完全可以,但是,您需要知道如何正确创建它们,才能获得更好的浏览器支持.确保它们具有含义"或角色"以提高可读性.使用Web组件时很棒.
Creating custom HTML tags are perfectly fine nowadays, however, you need to know how to properly create them, for a better browser support. Make sure they have a "meaning", or "role" for better readability. It is great when working with web components.
这是一篇有关创建自定义html元素的好文章: https://www.smashingmagazine.com/2014/03/introduction- to-custom-elements/
Here is a good article about creating custom html elements: https://www.smashingmagazine.com/2014/03/introduction-to-custom-elements/
这篇关于定义“自定义"商品是否是不好的做法? HTML标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!