{"id":22349069,"url":"https://github.com/afsify/css","last_synced_at":"2025-03-26T11:20:36.544Z","repository":{"id":261286714,"uuid":"873573291","full_name":"afsify/css","owner":"afsify","description":"Detailed notes on CSS fundamentals, from layouts to styling. Master essential techniques for modern, responsive web design. A quick reference for creating clean and effective styles.","archived":false,"fork":false,"pushed_at":"2024-11-06T17:16:02.000Z","size":154,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T12:32:51.289Z","etag":null,"topics":["css","notes","style"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afsify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T11:52:43.000Z","updated_at":"2024-11-06T17:16:06.000Z","dependencies_parsed_at":"2024-11-05T18:43:27.199Z","dependency_job_id":"7bd4f125-ae13-4344-88d2-02d48f3f4d0c","html_url":"https://github.com/afsify/css","commit_stats":null,"previous_names":["afsify/css"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsify%2Fcss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsify%2Fcss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsify%2Fcss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsify%2Fcss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afsify","download_url":"https://codeload.github.com/afsify/css/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245641430,"owners_count":20648646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","notes","style"],"created_at":"2024-12-04T11:07:16.520Z","updated_at":"2025-03-26T11:20:36.521Z","avatar_url":"https://github.com/afsify.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSS\n\n## What is CSS?\n\nCSS (Cascading Style Sheets) is a stylesheet language used to describe the presentation of a document written in HTML or XML. CSS controls the layout, colors, fonts, and overall visual appearance of a web page. It allows developers to create visually engaging websites and separate content (HTML) from presentation (CSS).\n\n## Uses\n\nCSS is commonly used for:\n\n- **Styling HTML Elements:** Applying colors, fonts, layouts, and spacing to HTML content.\n  \n- **Responsive Design:** Ensuring websites look good on all devices, from desktops to smartphones.\n\n- **Animations:** Creating dynamic effects and transitions for user interfaces.\n\n- **Web Layouts:** Implementing modern grid and flexbox layouts for responsive and adaptive designs.\n\n## Important Topics\n\n### 1. Selectors\n\nCSS selectors target HTML elements for styling. They can be simple like element or class selectors, or more advanced like attribute or pseudo-class selectors.\n\n**Example:**\n\n```css\n/* Select all \u003cp\u003e elements */\np {\n  color: blue;\n}\n\n/* Select an element with the class 'container' */\n.container {\n  width: 100%;\n}\n```\n\n### 2. Box Model\n\nThe CSS box model defines the structure of elements in a webpage. It includes margins, borders, padding, and the content area.\n\n**Example:**\n\n```css\ndiv {\n  padding: 10px;\n  border: 1px solid black;\n  margin: 20px;\n}\n```\n\n### 3. Flexbox\n\nFlexbox is a layout model that provides an efficient way to align and distribute space among items in a container.\n\n**Example:**\n\n```css\n.container {\n  display: flex;\n  justify-content: center;\n  align-items: center;\n}\n```\n\n### 4. Grid\n\nCSS Grid is a layout system designed for creating complex web layouts by using rows and columns.\n\n**Example:**\n\n```css\n.container {\n  display: grid;\n  grid-template-columns: repeat(3, 1fr);\n}\n```\n\n## Key Features\n\n1. **Separation of Content and Design:** CSS allows content (HTML) to be separated from its design, promoting cleaner and more maintainable code.\n\n2. **Responsive Web Design:** CSS features like media queries help build websites that adapt to various screen sizes.\n\n3. **Box Model:** Understanding the box model is crucial for controlling the spacing and sizing of elements.\n\n4. **Flexbox and Grid:** Flexbox and Grid provide powerful layout capabilities, making complex designs easier to implement.\n\n5. **Animations and Transitions:** CSS allows developers to create smooth animations and transitions, enhancing user experience.\n\n6. **Selectors and Combinators:** CSS provides a variety of selectors and combinators to target HTML elements precisely for styling.\n\n## Best Practices for CSS\n\nBelow are some best practices to follow for writing efficient and maintainable CSS:\n\n### Use Classes Over IDs\n\nIDs are unique to a single element, whereas classes can be reused. It's better to use classes for styling purposes.\n\n**Example:**\n\n```css\n/* Avoid */\n#header {\n  background-color: blue;\n}\n\n/* Prefer */\n.header {\n  background-color: blue;\n}\n```\n\n### Organize Your CSS\n\nOrganize your CSS by breaking it into sections such as typography, layout, and components to make it easier to maintain.\n\n### Minimize Use of Inline Styles\n\nAvoid using inline styles, as they increase maintenance difficulty and do not allow for separation of concerns.\n\n**Example:**\n\n```html\n\u003c!-- Avoid --\u003e\n\u003cp style=\"color: red;\"\u003eHello World\u003c/p\u003e\n\n\u003c!-- Prefer --\u003e\n\u003cp class=\"text-red\"\u003eHello World\u003c/p\u003e\n```\n\n### Use CSS Variables\n\nCSS Variables allow you to reuse values throughout your CSS, making your styles more consistent and maintainable.\n\n**Example:**\n\n```css\n:root {\n  --main-color: blue;\n}\n\nbody {\n  color: var(--main-color);\n}\n```\n\n### Responsive Design with Media Queries\n\nUse media queries to adjust your styles based on the screen size.\n\n**Example:**\n\n```css\n/* Mobile Styles */\n@media (max-width: 600px) {\n  .container {\n    flex-direction: column;\n  }\n}\n```\n\n### Avoid Over-Specificity\n\nAvoid over-specifying your CSS selectors, as it makes overriding styles more difficult.\n\n**Example:**\n\n```css\n/* Avoid */\ndiv p .container h1 {\n  color: green;\n}\n\n/* Prefer */\nh1 {\n  color: green;\n}\n```\n\n## Getting Started\n\nTo get started with CSS, follow these steps:\n\n1. **Linking a CSS File:** Create a new CSS file and link it in your HTML file.\n\n    ```html\n    \u003clink rel=\"stylesheet\" href=\"styles.css\"\u003e\n    ```\n\n2. **Start Styling:** Add your styles to the CSS file and apply them to your HTML elements.\n\n    ```css\n    body {\n      font-family: Arial, sans-serif;\n      background-color: #f4f4f4;\n    }\n    ```\n\n## Common CSS Properties\n\n**Change Text Color:**\n\n```css\np {\n  color: red;\n}\n```\n\n**Set Background Color:**\n\n```css\nbody {\n  background-color: #f0f0f0;\n}\n```\n\n**Center Elements:**\n\n```css\n.container {\n  display: flex;\n  justify-content: center;\n  align-items: center;\n}\n```\n\n**Add Padding and Margin:**\n\n```css\n.element {\n  padding: 10px;\n  margin: 20px;\n}\n```\n\n## Clone the Repository\n\nIn the terminal, use the following command:\n\n```bash\ngit clone https://github.com/afsify/css.git\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafsify%2Fcss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafsify%2Fcss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafsify%2Fcss/lists"}