Frontend Technologies-CSS/SCSS |
Learn more |
---|---|
CSS (Cascading Style Sheets) and SCSS (Sassy CSS) are stylesheet languages used for describing the presentation and styling of web documents written in HTML and XML. CSS is a core technology for web design, and SCSS is an extension of CSS that adds powerful features to make writing and maintaining stylesheets more efficient.
Here's an overview of both CSS and SCSS:
CSS (Cascading Style Sheets):
Syntax: CSS uses a simple, declarative syntax to define the style and layout of web pages. It consists of rulesets that define how HTML elements should be styled.
Selectors: CSS selectors are used to target HTML elements to apply styles to. Common selectors include element selectors (e.g., p, h1), class selectors (e.g., .btn), and ID selectors (e.g., #header).
Properties and Values: CSS properties define various style attributes such as color, font size, margin, padding, and more. Each property is followed by a value (e.g., color: red;, font-size: 16px;).
Cascading: The "C" in CSS stands for "Cascading," which means that styles can be inherited from parent elements, and styles can be overridden by more specific rules or rules defined later in the stylesheet.
External Stylesheets: CSS styles can be defined in external .css files and linked to HTML documents, making it easy to maintain and reuse styles across multiple web pages.
SCSS (Sassy CSS):
Syntax: SCSS is a superset of CSS, meaning that all valid CSS is also valid SCSS. It extends CSS with additional features and uses a more concise, less repetitive syntax.
Variables: SCSS allows you to define variables that can store values, such as colors, font sizes, or spacing values. This makes it easier to maintain a consistent style throughout your stylesheets.
Nesting: SCSS supports nesting of CSS rules within other rules. This reflects the HTML structure and makes the code more organized and readable.
Mixins: SCSS provides mixins, which are reusable blocks of CSS that can be included in other rules. Mixins allow you to avoid duplicating code and make your stylesheets more maintainable.
Operators and Functions: SCSS includes mathematical operators and functions, allowing you to perform calculations and manipulate values directly within your stylesheets.
Importing: SCSS supports importing other SCSS files, which helps organize your styles into modular components.
Semicolons and Curly Braces: While CSS uses semicolons and curly braces for declarations and blocks, SCSS allows you to omit them for cleaner and more concise code.
File Extension: SCSS files typically use the .scss file extension.
When working on web development projects, you can choose between CSS and SCSS based on your needs. CSS is the fundamental stylesheet language, and SCSS extends it with features that make stylesheet development more efficient and maintainable. Tools like Sass, Less, or PostCSS can also be used to preprocess and compile SCSS into standard CSS for use in web applications.
Lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt labore et dolore magna aliquyam erat sed diam voluptua.