Skip to content
css-fundamentals logo

CSS Fundamentals Skill

css-fundamentals

CSS fundamentals - selectors, specificity, box model, positioning, units

SKILL.md

Full skill instructions

CSS Fundamentals Skill

Master core CSS concepts: selectors, specificity, box model, positioning, and units.

Overview

This skill provides atomic, focused guidance on CSS fundamentals with type-safe parameters and comprehensive validation.

Skill Metadata

PropertyValue
CategoryCore CSS
ComplexityBeginner to Intermediate
DependenciesNone
Bonded Agent01-css-fundamentals

Usage

Skill("css-fundamentals")

Parameter Schema

parameters:
  topic:
    type: string
    required: true
    enum: [selectors, specificity, box-model, positioning, units, display]
    description: The CSS fundamental topic to explore

  level:
    type: string
    required: false
    default: beginner
    enum: [beginner, intermediate, advanced]
    description: Depth of explanation

  include_examples:
    type: boolean
    required: false
    default: true
    description: Include code examples

validation:
  - rule: topic_required
    message: "Topic parameter is required"
  - rule: valid_enum
    message: "Topic must be one of: selectors, specificity, box-model, positioning, units, display"

Topics Covered

Selectors

  • Element, class, ID selectors
  • Attribute selectors [attr], [attr=value]
  • Pseudo-classes :hover, :focus, :nth-child()
  • Pseudo-elements ::before, ::after
  • Combinator selectors >, +, ~

Specificity

  • Specificity calculation (0,0,0,0)
  • Cascade order rules
  • !important usage and pitfalls
  • Inheritance patterns

Box Model

  • Content, padding, border, margin
  • box-sizing: border-box vs content-box
  • Margin collapse behavior
  • Inline vs block dimensions

Positioning

  • static, relative, absolute, fixed, sticky
  • Stacking context and z-index
  • Containing block rules
  • Offset properties (top, right, bottom, left)

Units

  • Absolute: px, pt, cm
  • Relative: em, rem, %, vh, vw
  • Newer units: ch, lh, cqi, cqw
  • When to use which unit

Retry Logic

retry_config:
  max_attempts: 3
  backoff_type: exponential
  initial_delay_ms: 1000
  max_delay_ms: 10000
  retryable_errors:
    - TIMEOUT
    - RATE_LIMIT
    - TEMPORARY_FAILURE

Logging & Observability

logging:
  entry_point: skill_invoked
  exit_point: skill_completed
  log_parameters: true
  log_response_size: true
  metrics:
    - invocation_count
    - success_rate
    - avg_response_time

Quick Reference

Specificity Calculator

Inline styles    → 1,0,0,0
ID selectors     → 0,1,0,0
Classes/​attrs    → 0,0,1,0
Elements         → 0,0,0,1

Example: div#header .nav a:hover
         0,1,2,2 (ID=1, class+pseudo=2, elements=2)

Box Model Visual

┌─────────────────────────────────┐
│           MARGIN                │
│   ┌─────────────────────────┐   │
│   │        BORDER           │   │
│   │   ┌─────────────────┐   │   │
│   │   │    PADDING      │   │   │
│   │   │   ┌─────────┐   │   │   │
│   │   │   │ CONTENT │   │   │   │
│   │   │   └─────────┘   │   │   │
│   │   └─────────────────┘   │   │
│   └─────────────────────────┘   │
└─────────────────────────────────┘

Unit Recommendations

Use CaseRecommended Unit
Typographyrem
Spacingrem or em
Borderspx
Viewport layoutsvh, vw, %
Container layouts% or fr

Code Examples

Selector Efficiency

/​* Efficient: Single class */
.nav-link { }

/​* Less efficient: Descendant chain */
nav ul li a { }

/​* Prefer attribute selectors */
[data-state="active"] { }

Box Model Reset

*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

Test Template

describe('CSS Fundamentals Skill', () => {
  test('validates topic parameter', () => {
    expect(() => skill({ topic: 'invalid' }))
      .toThrow('Topic must be one of: selectors, specificity...');
  });

  test('returns selector examples for selectors topic', () => {
    const result = skill({ topic: 'selectors', level: 'beginner' });
    expect(result).toContain('.class');
    expect(result).toContain('#id');
  });

  test('handles missing optional parameters', () => {
    const result = skill({ topic: 'box-model' });
    expect(result.level).toBe('beginner');
    expect(result.include_examples).toBe(true);
  });
});

Error Handling

Error CodeCauseRecovery
INVALID_TOPICUnknown topicShow valid topics list
LEVEL_MISMATCHLevel too advanced for topicSuggest appropriate level
PARAM_VALIDATIONInvalid parameter typeReturn validation message

Related Skills

  • css-flexbox-grid (layout builds on fundamentals)
  • css-architecture (naming builds on selectors)
  • css-modern (extends selector knowledge)

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View