Info
Demo 2.2
CSS classes
A class is a name you invent and attach to any number of elements, so you can style exactly the ones you mean.
<p class="callout">Hello</p>
.callout {
border-left: 4px solid crimson;
}
Note the dot. In CSS the selector is .callout; in HTML the attribute value is just callout. Everybody gets this wrong at least once.
Classes, ids, elements
pstyles every paragraph on the page..calloutstyles every element carrying that class ~ as many as you like.#herostyles the single element with that id.
Why I use classes for almost everything
Element selectors are too broad: the moment you want one paragraph to look different, you’re stuck. Ids are too narrow: you can only use them once, and they’re hard to override later (there’s a demo on that coming). Classes sit in the middle, and you can stack several on one element.
Naming them
Name a class after what it is, not what it looks like. .warning still makes sense after you change the colour from red to orange. .red-box does not.
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
›