Skip to content

thedaviddias/Front-End-Checklist / skills/charset

charset

Verified

Use when reviewing templates, rendered HTML, or shared components related to Declare UTF-8 character encoding. Validate the final browser-facing markup, not just the source framework abstraction.

FileKindSize
SKILL.mdskill md1.5 KB
references/rule.mdmarkdown2.8 KB

references/rule.md

View on GitHub
# Declare UTF-8 character encoding

> The charset (UTF-8) is declared correctly as the first element in the head.

**Priority:** critical · **Difficulty:** beginner · **Time:** 5 min

---
The UTF-8 character set must be declared early in the HTML head to ensure proper character rendering across all languages and symbols.

## Code Example

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Page Title</title>
</head>
<body>
    <!-- Content with international characters: Café, 北京, العربية -->
</body>
</html>
```

## Why It Matters

- **International Support**: Enables proper display of all Unicode characters
- **Security**: Prevents character encoding attacks
- **Early Declaration**: Must be within first 1024 bytes of document
- **Consistency**: Ensures same rendering across all browsers and platforms

## Framework Examples

  Front-End Checklist</title>
  </head>
</html>
```
  
  Vite App</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.tsx"></script>
  </body>
</html>
```
  
  
```tsx
// app/layout.tsx

  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}
```
```
// Next.js emits UTF-8 automatically in the document head.
// Verify the rendered HTML rather than adding a duplicate meta charset tag.
```
  
  
        <meta charSet="UTF-8" />
      
      <div>Your app content</div>
    </>
  )
}
```
  

## Best Practices

✅ **Position Early**: Place as first meta tag
```html
<head>
    <meta charset="UTF-8">
    <!-- Other meta tags follow -->
</head>
```

✅ **Use UTF-8**: Universal character support
```html
<meta charset="UTF-8">
```

❌ **Avoid Old Syntax**: Don't use verbose XHTML syntax
```html
<!-- Don't use this -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
```

## Tools & Validation

- [W3C Markup Validator](https://validator.w3.org/)
- [HTML5 Validator](https://html5.validator.nu/)
- Browser DevTools Network tab to check response headers

## Standards

- Use MDN: HTML as the standard for the final rendered HTML and browser-facing behavior.
- Use WHATWG HTML Living Standard as the standard for the final rendered HTML and browser-facing behavior.

## Verification

### Automated Checks

- Inspect the final rendered HTML in the browser or page source to confirm the rule is satisfied.
- Validate the affected markup with browser tooling or an HTML validator where appropriate.
- Test one representative route or template that uses the pattern.
- Re-check shared components that emit the same markup so the fix is consistent.

### Manual Checks

- Verify the rendered browser behavior manually on representative routes and supported browsers so the user-facing outcome matches the rule.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies 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 colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall