现代 CSS:自定义属性

An <aside> element represents content that is tangentially related to the main content of the page — like a sidebar note, a definition box, or a related-links section. It's not the same as a generic sidebar.

Declaring a custom property

Custom properties (officially "CSS Custom Properties for Cascading Variables Module") are declared with a double-dash prefix and defined on an element so they cascade down its descendants.

:root {
  --color-primary: #4f46e5;
  --radius-lg: 14px;
  --spacing: 16px;
}

Using the variable

Reference a custom property with var(--name). If the variable is not defined, you can provide a fallback as the second argument.

.button {
  background: var(--color-primary, #0066cc);
  padding: calc(var(--spacing) * 2);
  border-radius: var(--radius-lg);
}

Semantic rule: <aside> is for tangential content that could be removed without breaking the main narrative. If it's required reading, use <section> or keep it in the flow.