Css 1
Css 1
1. Introduction to CSS
Definition: CSS (Cascading Style Sheets) is used to style and layout web pages.
Purpose: To separate content (HTML) from design (CSS).
Syntax:
o Selector { property: value; }
o Example: h1 { color: blue; }
CSS Syntax:
o Selector: Targets the HTML element.
o Declaration Block: Contains properties and values.
Types of Selectors:
o Universal Selector: *
o Element Selector: h1, p, div
o Class Selector: .classname
o ID Selector: #idname
o Attribute Selector: [type="text"]
3. Types of CSS
Inline CSS: Directly inside HTML elements using the style attribute.
Internal CSS: Within the <style> tag in the <head> section of HTML.
External CSS: Linked via a .css file using the <link> tag.
Components:
o Content
o Padding
o Border
o Margin
Explanation: The box model affects the layout and spacing of elements.
Text Properties:
o color
o font-size
o font-family
o text-align
o text-decoration
Background Properties:
o background-color
o background-image
o background-position
o background-size