HTML元素:属性排序 [英] HTML element : Attribute ordering

查看:99
本文介绍了HTML元素:属性排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

分析几个页面并注意到不同的方法/写作风格,我想知道HTML元素属性的顺序是否有效: b

  • 浏览器性能

  • 渲染(显而易见或不可)
  • 客户机/服务器计算资源

  • 什么?



他们是我应该考虑的排序标准吗?



我只能想



 它会影响JQuery选择的第n个属性。 < div class =fooid =bar>< / div> 

vs

 < div id =barclass =foo>< / div> 


解决方案

在查询方面:


  • 为选择器O(1)使用ID而不是按类O(n)选择
  • 使用类来选择多个元素,只有一个元素的选择的ID(这将导致你只使用一个id或一个类,通常从来都不是)



在渲染方面:




Analyzing several pages and noticing different approaches/writing styles, I am wondering if the order of HTML element attributes effect:

  • browser performance
  • rendering (noticeable or not)
  • client/server computational resources
  • anything?

Is their a standard for the ordering that I should consider?

I can only think of it effecting JQuery selections of nth attribute.

ie:

<div class="foo" id="bar"></div>

vs

<div id="bar" class="foo"></div>

解决方案

On the querying side:

  • Using IDs for selectors O(1) instead of selecting by class O(n)
  • Use classes for selections of multiple elements, IDs for selections with only one element (this will cause you to only use either an id or a class, usually never both)

On the rendering side:

这篇关于HTML元素:属性排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆