Lecture 5 CSS pre-doing

Press right arrow

Instructions

Why?


		<!DOCTYPE html>
		<html>
		<head>
			<link rel="stylesheet" href="style.css">
			<style>
				a { color: gray; }
			</style>
		</head>
		<body>
			<h1 style="color: #f06">Title</h1>
		</body>
		</html>
	

3 ways to apply CSS to your page:

CSS rules

h1 { font-size: 200%; color: white; }

What if we want to use different criteria than type of element?

Group by… Example selector Matches…
id #about <section id="about">
class .message <p class="tip message"> <p class="warning message">
attribute presence [href] <a href="http://designftw.mit.edu"> <a href> <link rel="stylesheet" href="style.css"> but not <a>
attribute value [type="range"] <input type="range"> <yolo type="range"> but not <input type="number">

#about

ID selector

Matches…

<section id="about"> <main id="about">

Doesn’t match…

<section id="about-me"> <input name="about">

.notice

Class selector

Matches…

<p class="tip notice"> <div class="notice"> <p class="important notice warning">

Doesn’t match…

<notice> <p class="foo"> <div class="warning-notice">

[href]

Attribute presence selector

Matches…

<a href="http://designftw.mit.edu"> <a href> <link rel="stylesheet" href="style.css">

Doesn’t match…

<a> <a hreflang="fr">

[type="range"]

Attribute equality selector

Matches…

<input type="range"> <yolo type="range">

Doesn’t match…

<input type="number">

Simple Selectors

Most Common selectors * element .class #id
Attribute selectors [attr] [attr="value"] [attr^="starts"] [attr$="ends"] [attr*="anywhere"]

CSS @-rules

@font-face { font-family: 'Reenie Beanie'; src: url(https://fonts.gstatic.com/...woff2); }
Colors in CSS

Backgrounds & Images

Gradients

CSS resources