.CSS Cascading Style Sheets
.css

Cascading Style Sheets

CSS (.css) files define the visual presentation of HTML documents — colors, layout, typography, and animations. FileDex provides local CSS format reference and analysis directly in your browser with no file uploads and no server processing.

بنية الصيغة
Header schema
Records structured data
Stylesheet LanguageText FormatW3C StandardUTF-81996
بواسطة FileDex
غير قابل للتحويل

Style sheet format. Conversion is not applicable.

أسئلة شائعة

What is the difference between CSS and SCSS?

SCSS (Sassy CSS) is a superset of CSS that adds variables ($color), nesting, mixins, and functions. SCSS files must be compiled to standard CSS before browsers can use them. All valid CSS is also valid SCSS, so migration is incremental.

Is CSS render-blocking?

Yes. Browsers pause rendering until all CSS in the document head is downloaded and parsed. This is by design — rendering without styles causes a flash of unstyled content. Minimize blocking by inlining critical CSS and deferring non-critical stylesheets with media attributes or JavaScript loading.

How do I remove unused CSS from my project?

Use PurgeCSS or the built-in content scanning in Tailwind CSS to analyze your HTML and JavaScript for referenced class names, then strip any CSS rules that match no elements. This can reduce stylesheet size by 80-95% in framework-heavy projects.

Can CSS be used for animations without JavaScript?

Yes. CSS @keyframes and transition properties handle most animation needs — hover effects, loading spinners, slide-in panels, and scroll-driven animations. CSS animations are GPU-accelerated for transform and opacity changes, making them more performant than JavaScript alternatives for visual transitions.

ما يميز .CSS

What is a CSS file?

CSS (Cascading Style Sheets) is a stylesheet language that controls the visual presentation of HTML documents. It defines colors, fonts, layouts, animations, and responsive design rules, separating content structure from visual styling. CSS was first proposed by Håkon Wium Lie in 1994 and has been maintained by the W3C ever since. The "cascading" in the name refers to how styles are applied in a priority order — inline styles override internal stylesheets, which override external files.

اكتشف التفاصيل التقنية

Every website you visit uses CSS. It is one of the three core web technologies alongside HTML (structure) and JavaScript (behavior).

How to open CSS files

  • Any text editor — Notepad, TextEdit
  • VS Code (Windows, macOS, Linux) — IntelliSense, live preview, Emmet shortcuts
  • Sublime Text (Windows, macOS, Linux) — Syntax highlighting
  • Any web browser — DevTools inspector (F12) lets you view and edit CSS live
  • WebStorm (Windows, macOS, Linux) — Full IDE with CSS validation

Technical specifications

Property Value
Current Version CSS3 (modular specification)
Encoding UTF-8
Type Stylesheet language
Preprocessors Sass, Less, Stylus
Standard W3C Recommendation
MIME type text/css

Common use cases

  • Web styling: Colors, fonts, spacing, borders, and background images
  • Layout: Flexbox and CSS Grid for responsive page structure
  • Responsive design: @media queries for mobile and desktop adaptation
  • Animations: @keyframes and transition properties for motion
  • Print styles: @media print for printer-friendly layouts
  • Frameworks: Bootstrap, Tailwind CSS, Bulma abstract common patterns into reusable classes

CSS selector types

CSS targets HTML elements through selectors:

/* Element selector */
h1 { color: #333; }

/* Class selector */
.button { padding: 8px 16px; }

/* ID selector */
#header { background: #fff; }

/* Pseudo-class */
a:hover { text-decoration: underline; }

/* Media query (responsive) */
@media (max-width: 768px) {
  .sidebar { display: none; }
}

CSS preprocessors

Raw CSS has no variables, functions, or nesting. Preprocessors extend it with these features and compile to standard CSS:

  • Sass / SCSS: Most popular; variables ($color), nesting, mixins, inheritance
  • Less: Similar to Sass, used heavily by Bootstrap 3
  • Stylus: More permissive syntax; less common

Modern CSS now natively supports custom properties (--variable-name) and nesting (in newer browsers), reducing the need for preprocessors.

Performance considerations

CSS is render-blocking — the browser must download and parse CSS before rendering. To minimize impact: place <link> tags in <head>, minify CSS for production, avoid deeply nested selectors, and use will-change and contain hints for animated elements. Critical CSS (the styles needed for above-the-fold content) can be inlined in HTML to accelerate first paint.

Developer tools

Browser DevTools (F12 in Chrome/Edge/Firefox) let you inspect any element's computed styles, toggle properties on/off, and experiment with CSS changes live. The Computed tab shows which styles are actually applied after the cascade resolves all conflicts.

المرجع التقني

نوع MIME
text/css
المطوّر
World Wide Web Consortium (W3C)
سنة التقديم
1996
معيار مفتوح
نعم — عرض المواصفات

البنية الثنائية

CSS files are plain-text documents encoded in UTF-8. There are no binary magic bytes or fixed headers. The file begins with rulesets — selectors followed by declaration blocks in curly braces. An optional `@charset "UTF-8";` declaration may appear as the very first bytes (before any whitespace or comments) to explicitly declare encoding, though UTF-8 is the default when no charset is specified. A UTF-8 BOM (EF BB BF) is permitted and takes precedence over @charset if present, but it can cause issues when concatenating multiple CSS files. Line endings (LF or CRLF) are normalized during parsing.

1994Hakon Wium Lie proposes Cascading HTML Style Sheets at CERN1996CSS1 published as a W3C Recommendation — fonts, colors, text alignment, margins1998CSS2 adds positioning, z-index, media types, and the @import rule2011CSS3 modular specification approach begins: Selectors Level 3, Media Queries, Transitions, Animations published as separate modules2012CSS Flexbox specification reaches Candidate Recommendation, enabling one-dimensional layout2017CSS Grid Layout ships in Chrome, Firefox, and Safari — two-dimensional layout without frameworks2022CSS Cascade Layers (@layer), Container Queries, and :has() selector ship across major browsers2023CSS Nesting ships natively in browsers, reducing the primary reason for Sass/Less preprocessors
Minify CSS with cssnano أخرى
npx cssnano input.css -o output.min.css

cssnano applies safe optimizations: merging duplicate rules, shortening color values (#ffffff to #fff), removing redundant units (0px to 0), and stripping comments. Output is functionally identical to the input.

Lint CSS with Stylelint أخرى
npx stylelint "**/*.css" --fix

Checks all CSS files for errors and style violations against configurable rules. --fix automatically corrects issues like shorthand property order, duplicate selectors, and invalid color functions.

Add vendor prefixes with Autoprefixer أخرى
npx postcss input.css --use autoprefixer -o output.css

Reads the browserslist configuration and adds required vendor prefixes (-webkit-, -moz-) for CSS properties that still need them in target browsers. Removes obsolete prefixes that are no longer necessary.

Format CSS with Prettier أخرى
npx prettier --write "**/*.css"

Rewrites all CSS files with consistent indentation, property ordering, and bracket placement. --write modifies files in place. Prettier handles CSS, SCSS, and Less syntax.

CSS MINIFIED CSS transcode lossless Minification strips comments, whitespace, and shortens values to reduce file size by 20-50%. Smaller CSS files reduce render-blocking time and improve First Contentful Paint scores.
SCSS CSS transcode lossless Sass/SCSS files use variables, nesting, and mixins that browsers cannot parse directly. The Sass compiler resolves all abstractions into standard CSS that any browser can render.
CSS POSTCSS-PROCESSED CSS transcode lossless PostCSS applies transformations like autoprefixing vendor prefixes, polyfilling newer CSS features for older browsers, and removing unused rules — producing a production-optimized stylesheet.
متوسط

نقاط الضعف

  • CSS injection: attacker-controlled input in style attributes or stylesheet imports can alter page appearance to facilitate phishing or hide content
  • Data exfiltration via attribute selectors: input[value^='a'] rules with background-image URLs can leak form values character-by-character to an external server
  • Keylogger via @font-face: combining unicode-range with external font requests can detect individual keystrokes in input fields
  • UI redressing: CSS repositioning of elements (opacity, z-index, position) can overlay fake UI on legitimate controls

الحماية: FileDex processes CSS files locally with no external resource loading, no @import resolution, and no network requests. Content Security Policy headers restrict style sources to same-origin.

Sass أداة
CSS preprocessor with variables, nesting, mixins, and functions
PostCSS أداة
Pluggable CSS transformer for autoprefixing, linting, and future CSS polyfills
Tailwind CSS أداة
Utility-first CSS framework that generates styles from class names in markup
Stylelint أداة
Modern CSS linter that catches errors and enforces consistent conventions
cssnano أداة
CSS minifier built on PostCSS that applies safe structural optimizations
Lightning CSS أداة
Extremely fast CSS parser, transformer, and minifier written in Rust