Cascading Style Sheet (Css)

  

CSS Notes


1. Introduction to CSS

1.1 What is CSS?
  • CSS (Cascading Style Sheets) is a stylesheet language used to describe the presentation of a document written in HTML or XML.
  • It controls the layout, colors, fonts, and spacing of web pages.
1.2 How to Use CSS

CSS can be applied in three different ways:

  1. Inline CSS: Defined within the HTML elements using the style attribute.
  2. Internal CSS: Defined in the <style> tag within the <head> section of an HTML document.
  3. External CSS: Defined in an external .css file, linked to the HTML document using the <link> tag.

2. CSS Syntax

2.1 CSS Rule Structure

A CSS rule consists of two parts:

  1. Selector: The HTML element you want to style.
  2. Declaration Block: The property-value pairs that define how the element will be styled.

selector { property: value; }

Example:

body {
background-color: lightblue; color: black; }

3. Selectors

3.1 Element Selector

Applies styles to all elements of a specific type.

p {
font-size: 16px; color: blue; }
3.2 ID Selector

Applies styles to an element with a specific id. The id selector is prefixed with #.

#header {
font-size: 24px; text-align: center; }
3.3 Class Selector

Applies styles to all elements with a specific class. The class selector is prefixed with ..

.button {
background-color: green; color: white; padding: 10px; }
3.4 Universal Selector

Applies styles to all elements on the page.

* {
margin: 0; padding: 0; }
3.5 Descendant Selector

Targets elements that are inside another element.

div p {
color: red; }

4. CSS Properties

4.1 Text Properties
  • font-family: Specifies the font of text.
  • font-size: Specifies the size of the text.
  • font-weight: Specifies the thickness of the text.
  • color: Specifies the color of the text.
h1 {
font-family: Arial, sans-serif; font-size: 32px; font-weight: bold; color: darkblue; }
4.2 Box Model Properties

The CSS box model describes the rectangular boxes generated for elements. It consists of the following:

  • content: The actual content of the element.
  • padding: The space between the content and the border.
  • border: The border around the padding (optional).
  • margin: The space outside the border.
div {
padding: 10px; border: 2px solid black; margin: 20px; }
4.3 Background Properties
  • background-color: Sets the background color of an element.
  • background-image: Sets a background image for an element.
  • background-size: Specifies the size of the background image.
body {
background-color: #f0f0f0; } div { background-image: url('background.jpg'); background-size: cover; }
4.4 Display and Positioning
  • display: Defines how an element is displayed. Common values: blockinlineinline-blocknone.
  • position: Specifies the position of an element. Common values: staticrelativeabsolutefixedsticky.
div {
display: block; position: relative; top: 20px; }
4.5 Borders and Shadows
  • border: Defines the border around an element.
  • border-radius: Rounds the corners of the element's border.
  • box-shadow: Adds shadow to an element.
div {
border: 1px solid black; border-radius: 10px; box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3); }

5. CSS Layout Techniques

5.1 Flexbox

The Flexbox layout allows you to distribute space dynamically between elements inside a container.

.container {
display: flex; justify-content: space-between; } .item { width: 30%; }
5.2 Grid

The CSS Grid layout allows you to create complex grid layouts with rows and columns.

.container {
display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .item { background-color: lightgray; }
5.3 Float

The float property is used to place elements next to each other.

div.left {
float: left; width: 50%; } div.right { float: right; width: 50%; }

6. CSS Pseudo-Classes and Pseudo-Elements

6.1 Pseudo-Classes

Pseudo-classes are used to define the special state of an element.

a:hover {
color: red; } input:focus { border-color: blue; }
6.2 Pseudo-Elements

Pseudo-elements are used to style specific parts of an element.

p::first-letter {
font-size: 2em; font-weight: bold; } div::before { content: "Important: "; font-weight: bold; }

7. CSS Transitions and Animations

7.1 CSS Transitions

CSS transitions allow you to change property values smoothly over a specified duration.

div {
background-color: blue; transition: background-color 0.5s ease; } div:hover { background-color: red; }
7.2 CSS Animations

CSS animations allow you to create more complex and continuous animations.

@keyframes example {
0% { background-color: blue; } 100% { background-color: red; } } div { animation: example 2s infinite; }

8. Media Queries

Media queries are used to apply different styles to different screen sizes or devices.

@media screen and (max-width: 600px) {
body { background-color: lightgray; } }

Assessment: Regular Tests, Assignments, and Final Project Evaluation

Certification: Certificate of Completion from Disha Institute

 

Number of Days Depends on your practice and feedback. The more you practice and review your work, the faster you will complete the course.

For Batch time and Fess contact to Below Address and Number.

Zamanat Sir

(MCA / Bsc. I.T / ‘A’ / ‘O’ / CCC / Govt. Certified  Domain Skill Trainer )

   Disha Institute 153 Vijay Nagar Opp. Rg Pg College W.K Road Meerut 

(9411617329 , 9458516690) 

Comments

Popular posts from this blog

VBA Modules for Excel Automation (Advance Excel)

Java Programming

Excel Shortcuts