html-css-best-practices
БесплатноБез исполняемых скриптовНе проверенSemantic HTML5, CSS custom properties, responsive design, and performance optimization for web development
от Hack23★ 15 звёзд на GitHubОб этом скилле
HTML/CSS Best Practices Skill
Purpose
This skill defines HTML and CSS best practices for building accessible, performant, and maintainable web interfaces, specifically for the Hack23 Homepage and related projects.
Rules
Semantic HTML5
MUST USE:
<header>for site/page header<nav>for navigation menus<main>for main content (one per page)<article>for self-contained content<section>for thematic grouping<aside>for tangential content<footer>for site/page footer<h1>-<h6>in hierarchical order (don't skip levels)<button>for interactive actions<a>for navigation<figure>and<figcaption>for images with captions<time datetime="">for dates/times
MUST NOT:
- Use
<div>when semantic element exists - Use
<span>for block-level content - Skip heading levels (e.g., h1 → h3)
- Use
<br>for spacing (use CSS) - Use tables for layout (use CSS Grid/Flexbox)
HTML Structure
MUST:
- Include
<!DOCTYPE html> - Set
langattribute on<html>element - Include charset:
<meta charset="UTF-8"> - Include viewport meta:
<meta name="viewport" content="width=device-width, initial-scale=1.0"> - Use descriptive
<title>(unique per page) - Include meta description
- Close all tags properly
- Use lowercase for element names and attributes
- Quote all attribute values
- Validate HTML with W3C validator
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Hack23 - Cybersecurity consulting with transparency">
<title>Hack23 - Cybersecurity Consulting</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<nav>...</nav>
</header>
<main>
<article>...</article>
</main>
<footer>...</footer>
</body>
</html>
CSS Organization
MUST:
- Use single external stylesheet (
styles.css) - Organize CSS logically:
- CSS Custom Properties (variables)
- Reset/normalization
- Base styles (html, body, headings)
- Layout (header, nav, main, footer)
- Components
- Utilities
- Media queries
- Use meaningful class names (BEM methodology recommended)
- Avoid
!important(use specificity correctly) - Group related properties
- Use shorthand properties where appropriate
- Comment complex sections
Example:
/* CSS Custom Properties */
:root {
--primary-color: #2c3e50;
--secondary-color: #3498db;
--text-color: #333;
--bg-color: #fff;
--max-width: 1200px;
--spacing-unit: 8px;
}
/* Base Styles */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: var(--text-color);
background-color: var(--bg-color);
line-height: 1.6;
margin: 0;
padding: 0;
}
/* Layout */
.container {
max-width: var(--max-width);
margin: 0 auto;
padding: 0 calc(var(--spacing-unit) * 2);
}
/* Components */
.button {
display: inline-block;
padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 3);
background-color: var(--primary-color);
color: white;
text-decoration: none;
border-radius: 4px;
transition: background-color 0.3s ease;
}
.button:hover,
.button:focus {
background-color: var(--secondary-color);
}
CSS Custom Properties (Variables)
MUST USE for:
- Colors (primary, secondary, backgrounds, text)
- Spacing (margins, padding multiples)
- Typography (font sizes, line heights)
- Breakpoints
- Transitions/animations
- Z-index values
Benefits:
- Easy theme switching
- Consistent values across site
- Easier maintenance
- Runtime updates possible
Responsive Design
MUST:
- Design mobile-first (base styles for mobile, media queries for larger screens)
- Use relative units (
rem,em,%,vw,vh) over fixedpx - Test at multiple breakpoints (320px, 768px, 1024px, 1440px+)
- Use CSS Grid or Flexbox for layouts
- Ensure touch targets are at least 44×44px
- Avoid horizontal scrolling
- Use
max-widthfor readability (60-80 characters per line)
Recommended Breakpoints:
/* Mobile-first base styles */
/* Tablet */
@media (min-width: 768px) {
/* Tablet styles */
}
/* Desktop */
@media (min-width: 1024px) {
/* Desktop styles */
}
/* Large Desktop */
@media (min-width: 1440px) {
/* Large desktop styles */
}
Performance Optimization
MUST:
- Minimize CSS file size (remove unused styles)
- Use CSS minification in production
- Avoid deep selector nesting (max 3 levels)
- Use efficient selectors (avoid universal
*) - Load CSS in
<head>(blocking is necessary) - Consider critical CSS for above-the-fold content
- Use
will-changesparingly for animations - Optimize images (WebP format, lazy loading)
Image Optimization:
<!-- Use WebP with fallback -->
<picture>
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Description" loading="lazy">
</picture>
<!-- For icons, prefer inline SVG -->
<
Установить html-css-best-practices в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл html-css-best-practices?
Semantic HTML5, CSS custom properties, responsive design, and performance optimization for web development
Как установить скилл html-css-best-practices?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл html-css-best-practices запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic