Note Style properties use camelCase (backgroundColor, not background-color). Values that need units must include them as strings ("8px"), except for unitless properties like opacity and zIndex which accept numbers.
Note Inline styles use camelCase property names and string/number values. They cannot handle pseudo-classes (:hover), media queries, or keyframe animations. Best for truly dynamic values that change at runtime.
Note A span has no semantic meaning. Use it purely for styling a portion of text when no better semantic element exists.
Frequently asked questions
How does React handle inline style?
This task is covered in 2 stacks on this page: React, HTML & CSS. The "Inline Style Objects" snippet in React uses `<div style={{ property: value }} />`.
Which code does the React example use?
The "Inline Style Objects" snippet uses `<div style={{ property: value }} />`, from the JSX section of the React cheat sheet.
Which stacks cover "inline style" on this page?
React, HTML & CSS. Together they hold 3 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Inline Style Objects": Style properties use camelCase (backgroundColor, not background-color). Values that need units must include them as strings ("8px"), except for unitless properties like opacity and zIndex which accept numbers.