CSS 3

SESSION 1 Session1 file pdf

Introduction

What we need ?

Extention file .css like main.css

Where can I create CSS Code ?

  1. External file
  2. internal
    • in file inside <head> <style></style> </head>
    • inline inside the opening tage what you want style it like <p> tage
Css-places

Full Priority Order (Simplified)


  1. Inline styles with !important
  2. Internal/External styles with !important
  3. Inline styles
  4. Internal styles between tag <style></style>
  5. External styles
  6. Browser default styles (lowest)

Selector & Comment

in CSS, comments are often used to:

  • Explain the code - for documentation
  • Sometimes using to ignor code to test or debug

Type of Comment :

  • Single Line /* .... * /
  • Multiple Line
commant

Some Types of Selector :

  • Universal Selector (*) : Example: * { margin: 0; } Selects all elements on the page.
  • Type Selector (Element Selector) : Example: p { color: red; } Selects all elements of a specific HTML tag (e.g., all <p> tags).
  • Class Selector : Example .note { font-size: 14px; } Selects all elements with a given class.
  • ID Selector : Example: #header { background: blue; } Selects the single element with a specific id.
  • Group Selector : Example: h1, p, div { margin: 0; } Applies the same style to multiple selectors.
  • Descendant Selector : Example: div p { color: green; } Selects all <p> elements inside a .

Background

We will take a <div> as example to implement

background-color

  • background-color: red;
  • background-color: rgb(107, 5, 5); or background-color: rgba(107, 5, 5,50%);
  • background-color: #eee;
background-color1
  1. You can type color by hexadecimal like #eee , #1f1f1f
  2. rgba : r -> Red color g -> Green color b -> Blur color a -> Alpha
  3. The alpha value must be a number between (0 and 1), not a percentage.

There are many great websites for discovering and generating beautiful color palettes for your designs

color hunt website

linear-gradient

The linear-gradient() function in CSS is used to create smooth transition between two or more colors along a straight line (vertical, horizontal, diagonal, etc.).

background: linear-gradient(direction, color-stop1, color-stop2, ...);

Examples :


background-image

background-repeat

background-attachment

background-position

background-size

background-repeat

background-attachment

background-size

background-position

Assignment

Challenge :

              Help Code :

              width:200px;
              height:250px;
              border:1px solid black;
            
background-img