Our Tech Journal
  • Introduction
  • Overview
    • Introduction
  • Javascript
    • JS Runtime, Env Context, Scopes, Hoisting & Execution Cycle, var/let/const, this
    • Javascript Runtime Env
      • Event loops
    • What are WebVitals
    • Module Patterns in JS - CommonJS, AMD and ES6 classes
    • Lexical Environment in JS
    • var vs let/const
    • Temporal Dead Zone (TDZ)
    • Execution Context
    • 'this' keyword
    • undefined value in JS
    • Function expressions vs Function statements
    • Javascript Code Execution
    • Closures
    • JS : Object Oriented Programming
    • Prototypal Inheritance
      • Creating Object in Javascript
    • NaN
    • Objects
      • Ways to create
      • ways to check if Object is empty
      • Object's own properties
    • use strict mode
    • typeof vs instanceof
    • Promise
    • localStorage and SessionStorage
    • Event handlers
    • Event bubbling
    • Event Delegation
    • XHR Request
    • Promise Error: Catch vs Error Function in Then
    • Immutability
    • Useful Code samples
    • window, document, screen
    • window.innerheight, outer height, screen.height
    • JS Design Patters
    • Interview Questions
    • Encapsulation - Module Patterns in JS
    • Redesigning services using Entity framework approach
  • JS Functions
    • JS Array - Slice vs Splice
  • PWA
    • What is PWA
  • ES6
    • Sets
    • Maps
    • spread vs destructure operator
  • Web
    • http / https
    • CORS
    • CSRF
    • XSS Attack
    • What is SPA
    • Semantic Elements in HTML
  • Angular 4
    • Angular vs React
    • Change Detection
    • Lazy Loading of modules
    • Preloading
    • AOT Compilation
    • Route Guards
    • Shared Modules
    • Tree Shaking
    • LifeCycle Hooks
    • ngRx
    • Observables
    • Observable vs Subject
      • BehaviorSubject
    • Observables vs Promises
    • Builtin Directives
      • Temp
      • Structural Directives
        • ngForTemp
        • ngSwitch
        • ngFor
        • ngIf
      • Attribute Directives
        • temp
        • ngClass
        • ngStyle
    • Routing
      • Routing in Angular
      • Setting up basic routing
      • routerLink and routerLinkActive
      • router.navigate and ActivatedRoute
      • Route Params as Observables
      • redirectTo
      • relativeTo
      • pathMatch
      • ActivatedRoute
      • Routing in Angular
      • Passing Data with Route
      • Route Parameters
    • Intercept HTTP request
    • Custom Directives
    • Communication between components
    • Angular Modules
    • Reactive Forms
    • Unit Testing
      • TestBed and component fixture
      • Testing HttpClient requests
      • Testing fakeAsync
  • GraphQL
    • Introduction
    • Server
    • Client Side
    • GraphQL in Angular
    • Queries
      • temp
      • query with parameters
      • aliases
      • fragments
      • @include directive
      • @skip directive
      • variables
      • Inline Fragments
  • CSS
    • What is Box model?
    • display: block, inline or inline-block
    • CSS Selector: Combinators
    • CSS Pseudo-classes
    • CSS Pseudo-elements
    • CSS3 Filter
    • CSS3 Transitions
    • Media Queries
    • Flex vs Grid
    • CSS 3 Grids
    • What is Flexbox?
    • position: relative vs absolute
  • SASS
    • Mixins
    • Lists
    • Maps
  • RxJS
    • throttle vs debounceTime
    • distinctUnitChange
    • reduce vs scan
  • Typescript
    • Typeguards
    • Pattern Matching with Typescript
    • TS Decorators
    • Using LINQ in TS
  • NodeJS
    • NodeJS Security Checklist
    • What is Node.js
  • REACT
    • React - VDOM - Under the hood
    • Synthetic events in React
    • Routing - React Router 4
    • React Custom hook
    • Higher-Order Component
    • REDUX
    • Redux Thunk vs Redux Saga
    • forceUpdate()
    • Storing Data in React
    • Error Handling
    • React Context
    • How React-Native works
    • refs
    • Server-side Rendering
    • Jest setup file
    • React-test-renderer
    • Lifecycle
    • React Testing Library
    • React Query
  • JWT
    • What is JWT and How it works
Powered by GitBook
On this page
  1. CSS

CSS Pseudo-classes

A pseudo-class is used to define a special state of an element.

For example, it can be used to:

  • Style an element when a user mouses over it

  • Style visited and unvisited links differently

  • Style an element when it gets focus

The syntax of pseudo-classes:

selector:pseudo-class {
  property: value;
}

CSS Pseudo Classes

Selector
Example
Example description

a:active

Selects the active link

input:checked

Selects every checked <input> element

input:disabled

Selects every disabled <input> element

p:empty

Selects every <p> element that has no children

input:enabled

Selects every enabled <input> element

p:first-child

Selects every <p> elements that is the first child of its parent

p:first-of-type

Selects every <p> element that is the first <p> element of its parent

input:focus

Selects the <input> element that has focus

a:hover

Selects links on mouse over

input:in-range

Selects <input> elements with a value within a specified range

input:invalid

Selects all <input> elements with an invalid value

p:lang(it)

Selects every <p> element with a lang attribute value starting with "it"

p:last-child

Selects every <p> elements that is the last child of its parent

p:last-of-type

Selects every <p> element that is the last <p> element of its parent

a:link

Selects all unvisited links

:not(p)

Selects every element that is not a <p> element

p:nth-child(2)

Selects every <p> element that is the second child of its parent

p:nth-last-child(2)

Selects every <p> element that is the second child of its parent, counting from the last child

p:nth-last-of-type(2)

Selects every <p> element that is the second <p> element of its parent, counting from the last child

p:nth-of-type(2)

Selects every <p> element that is the second <p> element of its parent

p:only-of-type

Selects every <p> element that is the only <p> element of its parent

p:only-child

Selects every <p> element that is the only child of its parent

input:optional

Selects <input> elements with no "required" attribute

input:out-of-range

Selects <input> elements with a value outside a specified range

input:read-only

Selects <input> elements with a "readonly" attribute specified

input:read-write

Selects <input> elements with no "readonly" attribute

input:required

Selects <input> elements with a "required" attribute specified

root

Selects the document's root element

#news:target

Selects the current active #news element (clicked on a URL containing that anchor name)

input:valid

Selects all <input> elements with a valid value

a:visited

Selects all visited links

PreviousCSS Selector: CombinatorsNextCSS Pseudo-elements

Last updated 2 years ago

:active
:checked
:disabled
:empty
:enabled
:first-child
:first-of-type
:focus
:hover
:in-range
:invalid
:lang(language)
:last-child
:last-of-type
:link
:not(selector)
:nth-child(n)
:nth-last-child(n)
:nth-last-of-type(n)
:nth-of-type(n)
:only-of-type
:only-child
:optional
:out-of-range
:read-only
:read-write
:required
:root
:target
:valid
:visited