在CSS2.1里,5.10 Pseudo-elements and pseudo-classes 描述了這兩個(gè)概念的由來,它們是被一同提及的。但到了 Selector Level 3 里,它們就被分開到兩個(gè)小節(jié)里加以區(qū)分。但無論如何,偽類和偽元素的引入都是因?yàn)樵谖臋n樹里有些信息無法被充分描述,比如CSS沒有“段落的第一行”之類的選擇器,而這在一些出版場(chǎng)景里又是必須的。用標(biāo)準(zhǔn)里的話說: CSS introduces the concepts of pseudo-elements and pseudo-classes to permit formatting based on information that lies outside the document tree. 簡(jiǎn)單翻譯一下,就是: CSS 引入偽類和偽元素的概念是為了實(shí)現(xiàn)基于文檔樹之外的信息的格式化 這么說很抽象,其實(shí)就是為了描述一些現(xiàn)有CSS無法描述的東西。缺少什么,則引入什么,不管是標(biāo)準(zhǔn),還是人,都是如此成長(zhǎng)而來。
<p>I am the bone of my sword. Steel is my body, and fire is my blood. I have created over a thoustand blades. Unknown to Death.Nor known to Life. Have withstood pain to create many weapon. Yet, those hands will never hold anything. So as I pray, unlimited blade works.</p>
<p><span class="first-line">I am the bone of my sword. Steel is my body, and fire is my blood. </span> I have created over a thoustand blades. Unknown to Death.Nor known to Life. Have withstood pain to create many weapon. Yet, those hands will never hold anything. So as I pray, unlimited blade works.</p>