वेब और HTML

CSS content प्रॉपर्टी

Unicode escapes का उपयोग करके ::before और ::after pseudo-elements के माध्यम से generated content सम्मिलित करने वाली CSS property: content: "\2713" ✓ सम्मिलित करता है।

· Updated

What Is the CSS content Property?

The CSS content property inserts generated content into a document via the ::before and ::after pseudo-elements. One of its most powerful uses is inserting Unicode characters using the \XXXXXX hex notation, allowing decorative symbols, icons, arrows, and glyphs to be added purely through stylesheets — without modifying the HTML.

The content property only applies to ::before and ::after pseudo-elements (and a few other generated content contexts like ::marker).

Unicode Notation in CSS

In CSS string values, Unicode escape sequences use a backslash followed by one to six hexadecimal digits:

/* These all insert the CHECK MARK ✓ (U+2713) */
.done::before {
  content: "\2713";        /* 4-digit hex */
  content: "\002713";      /* 6-digit hex */
  content: "✓";           /* direct UTF-8 character */
}

CSS Unicode escapes are terminated by: the end of the hex sequence (max 6 digits), an optional whitespace character (which is consumed and not displayed), or any non-hex character.

/* Terminating space is consumed — not rendered */
.icon::before {
  content: "\2713 Check";  /* renders: ✓Check (space consumed) */
}

/* No terminating space needed when followed by non-hex */
.icon::before {
  content: "\2713!";       /* renders: ✓! */
}

Common Use Cases

/* Quotation marks */
q::before { content: "\201C"; }   /* " (LEFT DOUBLE QUOTATION MARK) */
q::after  { content: "\201D"; }   /* " (RIGHT DOUBLE QUOTATION MARK) */

/* Arrows for navigation */
.next::after  { content: " \2192"; }  /* → */
.prev::before { content: "\2190 "; }  /* ← */

/* Decorative bullets */
.feature-list li::before {
  content: "\2022";  /* • BULLET */
  margin-right: 0.5em;
}

/* Warning icon */
.warning::before {
  content: "\26A0\FE0F";  /* ⚠️ (warning + emoji variation selector) */
}

/* External link indicator */
a[href^="http"]::after {
  content: " \2197";  /* ↗ NORTH EAST ARROW */
  font-size: 0.8em;
}

/* Counter combined with Unicode */
ol.custom {
  counter-reset: section;
}
ol.custom li::before {
  counter-increment: section;
  content: counter(section) "\FE0F\20E3";  /* Keycap emoji sequence */
}

Font Dependency

The inserted character renders using the element's computed font-family. If the font does not include a glyph for the specified code point, the browser falls back through the font stack. For full Unicode coverage, include a system emoji font or a comprehensive symbol font:

.icon::before {
  content: "\1F4A1";  /* 💡 LIGHT BULB */
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

Accessibility Considerations

Content generated with the content property is read by most screen readers (unless alt is set to empty string). For decorative characters, suppress them:

/* Decorative only — hide from screen readers */
.separator::before {
  content: "\2022";
  speak: never;        /* CSS Speech module (limited support) */
  /* Or use aria-hidden="true" on the element itself */
}

/* Meaningful content — provide alt text (CSS4) */
.external::after {
  content: "\2197" / "external link";
}

Quick Facts

Property Value
Applies to ::before and ::after pseudo-elements
Unicode syntax \XXXXXX (1–6 hex digits)
Terminator Optional single whitespace after hex sequence
Direct characters Allowed (UTF-8 source)
Max code point U+10FFFF (6 hex digits)
Accessibility Exposed to screen readers by default; use / "" alt to suppress
Font required Character must have a glyph in the computed font stack

वेब और HTML में और

Content-Type कैरेक्टर सेट

HTTP header parameter जो response की character encoding घोषित करता है (Content-Type: …

CSS Text Direction

CSS properties (direction, writing-mode, unicode-bidi) controlling text layout direction. Works with Unicode …

HTML इकाई

HTML में किसी वर्ण का पाठीय प्रतिनिधित्व। तीन रूप: named (&), decimal …

Internationalized Domain Name (IDN)

non-ASCII Unicode वर्ण युक्त domain names, आंतरिक रूप से Punycode (xn--...) के …

JavaScript Intl API

ECMAScript Internationalization API providing locale-aware string comparison (Collator), number formatting (NumberFormat), date …

Punycode

Unicode domain names का ASCII-compatible encoding, अंतर्राष्ट्रीयकृत labels को xn-- उपसर्ग वाले …

Unicode in CSS

CSS supports Unicode via escape sequences (\2713 for ✓), the content property …

XML वर्ण संदर्भ

XML का न्यूमेरिक कैरेक्टर रेफ़रेंस: ✓ या ✓। XML में केवल 5 …

इमोजी प्रस्तुति

किसी वर्ण को रंगीन emoji ग्लिफ़ के साथ रेंडर करना, आमतौर पर …

नामित वर्ण संदर्भ

मानव-पठनीय नाम का उपयोग करने वाली HTML entity: © → ©, — …