covering basic properties, important useful properties, Flexbox, and transitions/animations.
However, I am unable to create a PDF directly. You can easily copy and paste the generated
notes into a document editor (like Google Docs, Microsoft Word, or a text editor) and then
save or print it as a PDF.
Here are your CSS notes:
CSS Notes
Level 1: Introduction and Basic Properties
What is CSS?
* CSS stands for Cascading Style Sheets.
* It's a stylesheet language used to describe the presentation of a document written in
HTML or XML.
* CSS describes how HTML elements should be displayed on screen, paper, or in other
media.
* It separates the content (HTML) from its presentation (CSS), making web development
more efficient and maintainable.
How to Include CSS?
* Inline Styles:
* Applied directly to an HTML element using the style attribute.
* Example: <p style="color: blue; font-size: 16px;">This is blue text.</p>
* Use case: Small, specific style changes. Not recommended for large projects due to poor
maintainability.
* Internal (Embedded) Styles:
* Placed within the <style> tags in the <head> section of an HTML document.
* Example:
<head>
<style>
p{
color: green;
}
</style>
</head>
* Use case: Styles specific to a single HTML page.
* External Stylesheet (Most Common & Recommended):
* CSS rules are written in a separate .css file.
* Linked to the HTML document using the <link> tag in the <head> section.
* Example: <link rel="stylesheet" href="styles.css">
* Use case: Styling multiple HTML pages consistently. Highly maintainable and efficient.
Basic CSS Syntax
A CSS rule consists of a selector and a declaration block.
selector {
property: value;
property: value;
}
* Selector: Points to the HTML element(s) you want to style (e.g., p, h1, .my-class, #my-id).
* Declaration Block: Contains one or more declarations separated by semicolons.
, * Declaration: Includes a CSS property name and a value, separated by a colon.
Common Selectors
* Element Selector: Selects HTML elements by their tag name.
* Example: p { color: blue; } (selects all <p> elements)
* Class Selector: Selects HTML elements with a specific class attribute. Preceded by a dot
(.).
* Example: .my-text { font-weight: bold; } (selects elements with class="my-text")
* ID Selector: Selects a single HTML element with a specific id attribute. Preceded by a
hash (#). IDs must be unique within a page.
* Example: #header { background-color: lightgray; } (selects the element with id="header")
* Universal Selector: Selects all HTML elements. Preceded by an asterisk (*).
* Example: * { margin: 0; padding: 0; } (removes default margin/padding from all elements)
Basic Properties
Text Properties
* color: Sets the color of the text.
* Example: color: red;, color: #FF0000;, color: rgb(255,0,0);
* font-family: Specifies the font for text.
* Example: font-family: Arial, sans-serif;
* font-size: Sets the size of the text.
* Example: font-size: 16px;, font-size: 1em;, font-size: 1.2rem;
* font-weight: Sets how thick or thin characters in text should be displayed.
* Example: font-weight: normal;, font-weight: bold;, font-weight: 700;
* font-style: Specifies the font style (normal, italic, oblique).
* Example: font-style: italic;
* text-align: Aligns the text horizontally.
* Example: text-align: left;, text-align: right;, text-align: center;, text-align: justify;
* text-decoration: Adds or removes decorations from text.
* Example: text-decoration: none; (removes underline from links), text-decoration:
underline;
* line-height: Sets the height of a line of text.
* Example: line-height: 1.5;
* letter-spacing: Specifies the space between characters.
* Example: letter-spacing: 2px;
* word-spacing: Specifies the space between words.
* Example: word-spacing: 5px;
* text-transform: Controls the capitalization of text.
* Example: text-transform: uppercase;, text-transform: lowercase;, text-transform:
capitalize;
Box Model Properties (Margin, Border, Padding, Content)
Every HTML element is a rectangular box.
* width: Sets the width of an element's content area.
* Example: width: 100px;, width: 50%;
* height: Sets the height of an element's content area.
* Example: height: 200px;, height: auto;
* margin: Creates space around elements, outside of any defined borders.
* margin-top, margin-right, margin-bottom, margin-left