The snippet library.
Small, practical examples. Search by task or narrow things down below.
Show a pressed pointer state
CSS: Active applies during the pointer press rather than after the click has finished.
CSS✓ Tested
Show an element that was hidden
jQuery: Learn how to show an element that was hidden in a complete browser example.
jQuery✓ Tested
Show determinate progress
Represent known completion with an HTML progress element.
HTML✓ Tested
Show keyboard focus
Use a visible CSS outline when an input receives keyboard focus.
CSS✓ Tested
Show line numbers beside matches
Linux Commands: Use grep -n so a result identifies its position in the source file.
Linux Commands✓ Tested
Show progress with a native element
HTML: Learn how to show progress with a native element in a complete browser example.
HTML✓ Tested
Show the count of matching records
Show the count of matching records with a small React component and explicit browser behavior.
React✓ Tested
Show the current directory
Print the absolute path of your current working directory before running commands that depend on relative paths.
directory✓ Tested
Show the current value of a range input
HTML: Mirror range input events into a labeled output for a native slider.
HTML✓ Tested
Show the first lines of a file
Read only the first three lines of a text file, useful for checking a header or previewing a large log.
head✓ Tested
Show the Linux distribution version
Read the distribution-provided operating system name and version from os-release.
os✓ Tested
Size a child relative to its containing block
CSS: A percentage width is based on the containing block’s available width.
CSS✓ Tested