正确的部分和选择器部分的术语和词 [英] Correct terms and words for sections and parts of selectors

查看:155
本文介绍了正确的部分和选择器部分的术语和词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



用逗号分隔的CSS选择器部分的正确术语



  body.foo .login,body.bar .login {...} 
/ * |
Part 1 |第2部分* /

在这些部分中, (空格, + > 等)?

  body.foo .login,... {...} 
/ * |
Part 1 |第2部分* /


解决方案


以逗号分隔的CSS选择器部分的正确术语


目前,简单地称为选择器,这真的不适合我。 将来,它们将被更好地定义为复杂选择器



整个逗号分隔的列表称为选择器列表或组。


在这些部分中,由组合器分隔的部分(空格, + > 等)?


目前,简单选择器序列。以后,它们将被称为复合选择器



因此,选择器列表由一个或多个复杂选择器组成,逗号,每个复杂选择器由两个主要部分组成:复合选择器和组合器。它还可以包含伪元素。






自从我在这里,剩下的定义。 ..



选择器第3级总结如下:








选择器级别4 重新定义了一些术语,从而使事情更加模糊




  • 一系列简单选择器现在称为复合选择器


  • 名称复杂选择器现在赋予CSS3定义的选择器(即一个复合选择器字符串


  • 一组一个或多个复合/复合选择器现在称为选择器列表



    然而,如果你读某些函数式伪类的语法,那么这个术语本身就不会区分两者,它将描述他们正在寻找什么样的选择器列表。例如,增强了:not() pseudo-class 接受一个复合选择器列表,而原始版本只允许一个简单的选择器作为其参数。


  • 术语 selector 已被推广,因此为了简单和简洁起见,现在可以引用以下任何




    • 简单选择器

    • 复合选择器

    • 复杂选择器

    • 选择器列表(例如样式规则的选择器组件)



$ b b


一些个人笔记:




  • 是由浏览器供应商创造的,用于选择器实现,而不是官方术语。它通常用于表示选择器的主题,因为实现碰巧使用选择器的主题作为确定匹配的键。


  • p>术语伪选择器是由Web作者创造的混合伪类和伪元素,并且不是一个官方的,或者确实有意义的术语。虽然你可以在一些早期的W3C CSS2 / 3草稿中找到它,但这可能是一个错误。 请不要使用此字词,因为它不必要地创建


  • 伪元素( :: pseudo-element

    code>)不是简单的选择器,因此不能出现在只有实际元素可以匹配的地方。


  • CSS中的典型样式规则(或规则组)包含 selector 声明块


  • 命名空间前缀不是选择器,但可以应用于类型选择器


  • 特异性当前仅指单个复杂选择器的。匹配规则时,列表中与给定元素匹配的任何复杂选择器都将被考虑进行特异性计算。如果多个复杂选择器匹配一个元素,最具体的选择器将用于计算。



    特定性将是一个更复杂的问题与一些4级选择器, code>:nth-​​match():nth-​​last-match()。由于他们仍在投放,尚未决定如何实施任何此类操作。



What is the correct term for the sections of CSS selectors that are separated by commas?

    body.foo .login , body.bar .login { ... }
/*                  |
           Part 1   |  Part 2         */

Within those sections, what is the term for the parts separated by combinators (spaces, +, >, etc)?

    body.foo .login , ... { ... }
/*          |
   Part 1   |   Part 2    */

解决方案

What is the correct term for the sections of CSS selectors that are separated by commas?

Currently, these are simply called selectors, which really doesn't sit well with me. In future, they'll be better-defined as complex selectors.

The entire comma-separated list is known as a selector list or group.

Within those sections, what is the term for the parts separated by combinators (spaces, +, >, etc)?

Currently, these are called sequences of simple selectors. In future, they'll be known as compound selectors.

So, a selector list is made up of one or more complex selectors separated by commas, and each complex selector is made up of two main parts: compound selectors, and combinators. It can also optionally contain pseudo-elements.


And since I'm here, here are the rest of the definitions...

Selectors level 3 sums it up as follows:

  • A simple selector is one fundamental component of selectors. It is any one of the following:

  • A combinator is another fundamental component of selectors. It is a symbol or token that separates two compound selectors, establishing in its place a relationship between the two elements represented by the two compound selectors. There are currently four combinators in use today:

    • Descendant combinator:

      article p
      

    • Child combinator:

      /* 
       * The extra spaces in between are whitespace,
       * and are therefore insignificant.
       */
      ul > li
      

    • Adjacent sibling combinator:

      header + section
      

    • General sibling combinator:

      h2 ~ p
      

    More combinators may be introduced in later specifications.

  • A simple selector sequence is a chain of simple selectors not separated by a combinator:

    a:not([rel="external"]):hover
    

  • A selector (I hate this definition) is a complete string made up of selector sequences linked by combinators:

    nav[role="main"] > ul:first-child > li
    


Selectors level 4 redefines a number of terms and as a result makes things less ambiguous and less clumsy:

  • A sequence of simple selectors is now known as a compound selector.

  • The name complex selector is now given to the CSS3 definition of a "selector" (that is, a string of compound selectors and combinators).

  • A group of one or more compound/complex selectors is now formally known as a selector list. The term itself currently makes no distinction between the two, and I don't see this changing anytime soon.

    However if you read the grammar for certain functional pseudo-classes, it will describe what kind of selector lists they're looking for. For instance, the enhanced :not() pseudo-class accepts a list of compound selectors, whereas the original version only allowed a single simple selector as its argument.

  • The term selector has been generalized, so it may now refer to any of the following for the purposes of simplicity and brevity:

    • Simple selector
    • Compound selector
    • Complex selector
    • Selector list (e.g. the "selector" component of a style rule)

Some personal notes:

  • The term "key selector" is coined by browser vendors for use with selector implementations, and is not an official term. It is often used to mean "subject of the selector" however, because implementations happen to use the subject of the selector as the key for the purposes of determining matches.

  • The term "pseudo-selector" is coined by Web authors to mix pseudo-classes and pseudo-elements, and is not an official, or indeed meaningful, term. Although you can find it in some early-stage W3C CSS2/3 drafts, that was probably a mistake. Please don't use this term, as it needlessly creates confusion by attempting to group two completely different concepts into a single umbrella term.

  • Pseudo-elements (::pseudo-element) are not simple selectors, and therefore cannot appear in places where only actual elements may be matched. However, they are still considered selectors for the purposes of CSS parsing.

  • Typical style rules (or rulesets) in CSS consist of a selector and a declaration block.

  • Namespace prefixes are not selectors in their own right, but they may be applied to type selectors, universal selectors and attribute selectors to match components in a document that are (or are not) namespaced.

  • The specificity of a selector currently only refers to that of a single complex selector. When matching rules, any of the complex selectors in a list that match a given element will be considered for specificity calculations. If more than one complex selector matches an element, the most specific one will be used for calculations.

    Specificity will be a more complicated issue with some level 4 selectors, notably :nth-match() and :nth-last-match(). Since they're still being specced, it hasn't yet been decided how any of this will be implemented.

这篇关于正确的部分和选择器部分的术语和词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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