hubcap styles — Get all computed CSS styles of an element

When to use

Get all computed CSS styles of an element. Use computed for a single CSS property value.

Usage

hubcap styles <selector>

Arguments

ArgumentTypeRequiredDescription
selectorstringyesCSS selector of the element

Flags

None.

Output

FieldTypeDescription
selectorstringThe selector that was used
stylesobjectAll computed CSS property-value pairs
{"selector":".btn","styles":{"color":"rgb(0, 0, 0)","display":"block","font-size":"16px"}}

Errors

ConditionExit codeStderr
Element not found1error: element not found: <sel>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Get all styles of a button:

hubcap styles '.btn'

Get styles and extract just the background color:

hubcap styles '.btn' | jq -r '.styles["background-color"]'

See also

  • computed - Get a single computed CSS property
  • visible - Check if an element is visible
  • bounds - Get element bounding box
  • highlight - Highlight an element for debugging