Search Header Logo
CSS BASIC

CSS BASIC

Assessment

Presentation

Computers

Practice Problem

Hard

Created by

Prof. Tarik

Used 4+ times

FREE Resource

14 Slides • 0 Questions

1

What is CSS?

CSS is what we will use to make our webpages look nice and unique. They are separate files that we create that can be linked to our HTML to enhance the overall page.

media

2

Breakdown

  • Yellow: The first part is the "selector". This lets our HTML know what we are referring to.

  • Green: The next part is the entire declaration we are making.

  • Pink: Inside of the { } is where we will "declare" our style choices. "property: value;" pairs.

  • Orange: The first part of our pair is the "property" which states what type of style we are referring to.

  • Blue: The second part is the "value" which states the specific setting or numeric value we want to assign.

media

3

Classes and ID's

  • A 'class' is an attribute assigned to an HTML element. It can be assigned to as many different elements as we would like. It is best used though for elements that are used for the same purpose.

  • An 'id' is also an attribute assigned to an HTML element. It is a specific and unique value that cannot be used anywhere else.

media

4

Selectors and Specificity

  • General element selectors can be used to style every element in your HTML that matches the selector (least specific)

  • When a "." starts the selector we are referring to a "class". So any element with an attribute of 'class=bill-images' will be assigned the same style as each other. (more specific)

  • When a "#" starts the selector we are referring to an "id". Each "id" is unique and can only be applied once. The one element with the attribute of 'id=quote' will be assigned the style choices declared

media

5

3 Different ways to link CSS to HTML

  • 1) In-line (not best practice, gets messy, hard to keep track of, not DRY)

  • What is DRY? (Don't Repeat Yourself) The practice of trying to write code that can be used and re-used multiple times instead of writing it over and over and over... and over and over.

  • 2) Inside of the <style></style> element we can put inside of the <head></head> element in our HTML file. (Better than 'in-line', good for learning and working on small activities, still not best practice.)

  • 3) Create a separate file with a ".css" extension and <link> the file to our HTML. (Best practice, keeps our HTML and CSS separate and keeps our code clean. We love clean code.)

6

CSS in-line

Written inside of the HTML element, only pertains to that specific element.


"style='property: value' "

media

7

CSS <link>'ed!

Using a <link href="bill.css" rel="stylesheet" > inside of our <head> we can then write our CSS in a separate file to keep our code clean and easy to use.


This allows us to use our CSS on any HTML file we want to, by just adding a <link> in that HTML file. This helps with our practice of DRY coding.

media

8

media

9

media

10

media

11

media

12

media

13

media

14

media

What is CSS?

CSS is what we will use to make our webpages look nice and unique. They are separate files that we create that can be linked to our HTML to enhance the overall page.

media

Show answer

Auto Play

Slide 1 / 14

SLIDE