On this page10 sections
  1. Learning Objectives
  2. 1. Columns
  3. 2. resize
  4. 3. cursor
  5. 4. Selection, Caret and Pointer Events
  6. 5. Smooth Scrolling and Scroll Snap
  7. Common Beginner Mistakes
  8. Practice Questions
  9. Practice Answers
  10. Key Takeaways

Lecture 045: Multiple Columns & User Interface

Category7: Advanced Styling
Lecture045 of 057
Estimated video length10 min
TargetCSS3 · any modern browser
LevelIntermediate

Multi-column layout flows text into newspaper-style columns automatically. The user-interface properties control how people interact with elements: resizing boxes, the cursor shape, text selection, scrolling behaviour and even the caret colour.


Learning Objectives

  • Split text into columns with column-count and column-width
  • Style the gap and dividing line, and make headings span all columns
  • Use resize, cursor, user-select, caret-color and pointer-events
  • Control scrolling with scroll-behavior and scroll-snap

1. Columns

Example: drag the preview corner:

html
<style>
  .news { column-count: 3; column-gap: 28px; column-rule: 1px solid #dee2e6; font: 14px/1.6 Georgia, serif; }
  .news h3 { column-span: all; margin: 0 0 10px; font-family: system-ui; }
</style>

<div class="news">
  <h3>Spring arrives in Hunza</h3>
  <p>The apricot trees of Hunza burst into blossom every spring, painting the valley in pink and white. Visitors come from across the country to walk the terraced orchards.</p>
  <p>Local families have tended these trees for generations, drying the fruit in the summer sun on flat rooftops. Dried apricots are sold in markets all year round.</p>
  <p>The best time to visit is early April, when the snow-capped peaks still frame the blossoms and the days are cool and clear.</p>
</div>
PropertyDoes
column-count: 3Exactly three columns
column-width: 200pxAs many columns as fit, each at least 200px wide (responsive)
column-gapSpace between columns
column-ruleA dividing line (like a border)
column-span: allAn element (a heading) stretches across every column

columns: 200px 3 sets "at least 200px, at most three columns" in one line.


2. resize

Example: drag the bottom-right corners:

html
<div style="resize: both; overflow: auto; width: 200px; height: 80px; border: 2px dashed #74c0fc; padding: 8px;">resize: both</div>
<br>
<textarea style="resize: vertical; width: 260px;">Textareas can be limited to vertical resizing.</textarea>

resize only works when overflow is not visible.


3. cursor

Example: hover over each box:

html
<style>
  span { display: inline-block; padding: 8px 10px; margin: 3px; background: #f1f3f5; border-radius: 6px; font: 13px monospace; }
</style>

<span style="cursor: pointer;">pointer</span>
<span style="cursor: not-allowed;">not-allowed</span>
<span style="cursor: help;">help</span>
<span style="cursor: wait;">wait</span>
<span style="cursor: move;">move</span>
<span style="cursor: grab;">grab</span>
<span style="cursor: text;">text</span>
<span style="cursor: zoom-in;">zoom-in</span>
<span style="cursor: crosshair;">crosshair</span>

4. Selection, Caret and Pointer Events

Example

html
<p style="user-select: none; background: #fff3bf; padding: 6px;">user-select: none (try to select this)</p>
<p style="user-select: all; background: #d3f9d8; padding: 6px;">user-select: all: one click selects everything, e.g. a code to copy</p>
<input placeholder="caret-color: red" style="caret-color: #e03131; padding: 8px;">
<p><a href="#" style="pointer-events: none; color: #adb5bd;">pointer-events: none (this link can't be clicked)</a></p>
<style> ::selection { background: #b197fc; color: white; } </style>

accent-color (Lecture 024) recolours checkboxes, radios and sliders.


5. Smooth Scrolling and Scroll Snap

Example: swipe or scroll the row; each card snaps into place:

html
<style>
  .row { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
  .row div { flex: 0 0 70%; height: 100px; scroll-snap-align: center; border-radius: 10px; display: grid; place-items: center; color: white; font: 600 20px system-ui; }
</style>

<div class="row">
  <div style="background: #1971c2;">1</div><div style="background: #2f9e44;">2</div><div style="background: #e8590c;">3</div><div style="background: #7048e8;">4</div>
</div>
css
html { scroll-behavior: smooth; }   /* #anchor links glide instead of jumping */

Common Beginner Mistakes

1. Long paragraphs in narrow columns on phones. Use column-width, not a fixed column-count.

2. resize without overflow. It won't work while overflow is visible.

3. user-select: none on normal text. Visitors expect to be able to copy text.

4. pointer-events: none as a security measure. It only stops the mouse; keyboard users can still reach the element.


Practice Questions

  1. Split a paragraph into two columns with a 30px gap.
  2. How do you make a heading stretch across all columns?
  3. Which value of resize allows only up-and-down resizing?
  4. Which cursor suggests that something can't be clicked?
  5. How do you make anchor links scroll smoothly?
  6. Which two properties make a carousel snap to each card?

Practice Answers

  1. p { column-count: 2; column-gap: 30px; }
  2. column-span: all;
  3. resize: vertical;
  4. cursor: not-allowed;
  5. html { scroll-behavior: smooth; }
  6. scroll-snap-type on the container and scroll-snap-align on the items.

Key Takeaways

  • column-count / column-width, column-gap, column-rule and column-span make newspaper columns.
  • resize, cursor, user-select, caret-color and pointer-events shape interaction.
  • scroll-behavior: smooth and scroll snap make scrolling feel polished.