Info
Demo 2.3Inline CSS using
Inline CSS using style=""
You can put CSS directly on an element with the style attribute:
<p style="color: crimson">Hello</p>
No selector, no curly braces ~ you’re already pointing at the element.
Why I’d rather you didn’t
Inline styles beat almost everything else. That sounds handy right up until you want to change the colour of every paragraph and find yourself editing forty of them by hand. Worse, when a stylesheet rule mysteriously “doesn’t work”, an inline style is very often the reason.
They also can’t do :hover, @media queries, or animations. Those need a real stylesheet.
When they’re fine
- Passing one specific value in, like a custom property or a background image URL that changes per element.
- Quick throwaway tests. (This is most of what I use them for.)
- Code generated by a program, where a stylesheet isn’t practical.
For everything else: give it a class.
Keyboard Shortcuts
⌘ Z / ⌘ ⇧ ZCtrl Z / Ctrl ⇧ Z
Undo / redo
Tab / ⇧ TabTab / ⇧ Tab
Indent / unindent selection
⌘ ] / ⌘ [Ctrl ] / Ctrl [
Indent / unindent lines
⌘ ACtrl A
Select all
⌘ DCtrl D
Select next occurrence of selection
⌘ /Ctrl /
Comment / uncomment lines
Ctrl SpaceCtrl Space
Autocomplete
Ctrl EnterCtrl Enter
Reset layout
⌘ ⌥ [ / ⌘ ⌥ ]Ctrl ⇧ [ / Ctrl ⇧ ]
Fold / unfold block
Code
The editor didn't load — try refreshing the page. Navigation,
shortcuts and the info panel still work in the meantime.
Settings
View
Font size
14
Code
Preview
Delay
Zoom
Share
Reset
Preview
Currently previewing:
Dimensions0 × 0
Delay
Preview paused
Click to resume
Click to resume
The preview is disabled for this demo.
Use the console below.
Use the console below.
Console
›