Beginner
CASCADING STYLE SHEETS(CSS)
- 1 Section
- 60h Duration
CASCADING STYLE SHEETS(CSS)
Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation of a document written in a markup language, most commonly HTML or XHTML. It is a fundamental technology for web development, working in conjunction with HTML (for structure and content) and JavaScript (for interactivity).
CSS defines how elements of a web page are displayed, controlling aspects such as:
- Typography: Fonts, sizes, colors, text alignment, line height.
- Layout: Positioning of elements, creating grids or multi-column layouts, managing spacing and margins.
- Visual appearance: Backgrounds, borders, shadows, and other decorative features.
- Responsiveness: Adapting the layout and styling to different screen sizes and devices.
- Animations and transitions: Adding dynamic visual effects.
The "cascading" aspect of CSS refers to how styles are applied and prioritized. When multiple styles are defined for the same element, CSS follows a set of rules (specificity, order of rules, importance) to determine which style takes precedence. This allows for efficient and hierarchical styling, where general styles can be overridden by more specific ones.
CSS can be implemented in three ways:
-
External CSS:Styles are defined in a separate
.cssfile and linked to HTML documents. This is the recommended method for larger projects, promoting code organization and reusability. -
Internal CSS:Styles are embedded within the
<style>tags in the<head>section of an HTML document, applying only to that specific page. -
Inline CSS:Styles are applied directly to individual HTML elements using the
styleattribute. This method is generally discouraged for maintainability but can be useful for minor, element-specific adjustments.
