Structural Pseudo-classes
Structural pseudo-classes select elements based on their position in the document.
:first-child and :last-child
Select the first or last child element:
Loading Selector Playground...
Try:
li:first-child- first list itemli:last-child- last list item
:first-of-type and :last-of-type
Select first/last of a specific element type:
Loading Selector Playground...
p:first-of-type- first paragraphp:last-of-type- last paragraph:first-of-typeignores other element types
Styling Lists
Loading CSS Playground...
:only-child
Selects an element that is the only child:
Loading Selector Playground...
:empty
Selects elements with no children:
Loading Selector Playground...
Styling Empty States
Loading CSS Playground...
:not() Negation
Select elements that don't match a selector:
Loading Selector Playground...
Practical :not() Usage
Loading CSS Playground...
Exercise: Style First Item
Style the first list item differently:
Loading CSS Exercise...
التالي · الدرس 12 من 27
nth-child and nth-of-type
قراءة 2 دقيقة
أنهيت 11 من 27 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

