html css - massachusetts institute of...

89
HTML & CSS 6.148 Yolanda Zhou

Upload: others

Post on 24-May-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HTML & CSS

6.148Yolanda Zhou

go.6148.io/uiux

Page 2: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HTMLHypertext Markup Language

The language your web browser uses to describe the content and structure on web pages

Page 3: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body>

<h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 4: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 5: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 6: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 7: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HTML Tags

<html>

content goes here

</html>

Opening tag

Closing tag

Page 8: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 9: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HTML Tags

<a><b></a></b>

Page 10: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 11: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 12: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 13: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 14: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 15: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 16: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 17: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Basic HTML ElementsRoot of HTML DocumentInfo about DocumentDocument BodyHeader tagsParagraph tags

<html><head><body><h1>, <h2>, <h3>, …<p>

Page 18: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting LinksLink<a>

Link to 6.148!

Page 19: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HTML Attributes

<a href="link here">

content goes here

</a>

Opening tag

Closing tag

attribute value

Page 20: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting Links

<a href="http://6148.io">Link to 6.148!</a>

Link to 6.148!

Page 21: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting Links

<a href="home.html">Link to home!</a>

Link to home!

Page 22: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting ImagesImage<img>

Page 23: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting Images<img src="pusheen.gif"></img>

Page 24: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting Images<img src="pusheen.gif">

Page 25: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting Images<img src="pusheen.gif">

app/hello.htmlpusheen.gif

Page 26: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Inserting Images

app/hello.htmlimages/

pusheen.gif

<img src="pusheen.gif"><img src="images/pusheen.gif">

Page 27: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

ListsOrdered List (1, 2, 3…)Unordered List (bullets)

List Item

<ol><ul>

<li>

Page 28: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><ul></ul>

</body></html>

hello.html

Page 29: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><ul>

<li>Item 1</li></ul>

</body></html>

hello.html

• Item 1

Page 30: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><ul>

<li>Item 1</li><li>Item 2</li>

</ul></body>

</html>

hello.html

• Item 1• Item 2

Page 31: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

div & spanBlock Section in DocumentInline Section in Document

<div><span>

Page 32: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 33: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><div>

<h1>Heading!</h1><p>Paragraph!</p>

</div> </body>

</html>

hello.html

Page 34: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><div>

<h1>Heading!</h1><p>Paragraph!</p>

</div> </body>

</html>

hello.html

Page 35: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 36: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 37: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 38: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 39: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 40: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 41: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 42: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 43: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

CSSCascading Style Sheets

The rules that tell your web browser how stuff looks

Page 44: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 45: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic
Page 46: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

p {color: red;font-family: Arial;font-size: 24pt;

}

Page 47: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

p {color: red;font-family: Arial;font-size: 24pt;

}

selector

Page 48: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

p {color: red;font-family: Arial;font-size: 24pt;

}

selector

property

Page 49: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

p {color: red;font-family: Arial;font-size: 24pt;

}

selector

propertyvalue

Page 50: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

HeadingParagraph!

Page 51: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<h1>Heading!</h1><p>Paragraph!</p>

hello.html HeadingParagraph!

Page 52: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HeadingParagraph!

Info

<h1>Heading!</h1><p>Paragraph!</p><p>Info</p>

hello.html

Page 53: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HeadingParagraph!

Info

<h1>Heading!</h1><p>Paragraph!</p><p>Info</p>

hello.html

p {color: red;font-family: Arial;font-size: 24pt;

}

style.css

Page 54: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HeadingParagraph!

Info

<h1>Heading!</h1><p>Paragraph!</p><p class="info">Info</p>

hello.html

p {color: red;font-family: Arial;font-size: 24pt;

}

style.css

Page 55: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HeadingParagraph!

Info

.info {color: red;font-family: Arial;font-size: 24pt;

}

style.css

<h1>Heading!</h1><p>Paragraph!</p><p class="info">Info</p>

hello.html

Page 56: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

HeadingParagraph!

Info

#unique {color: red;font-family: Arial;font-size: 24pt;

}

style.css

<h1>Heading!</h1><p>Paragraph!</p><p id="unique">Info</p>

hello.html

Page 57: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

ClassCan use the same class on multiple elementsCan use multiple classes on the same element

Class vs IDIDEach element can have only one IDEach page can have only one element with that ID

Page 58: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Combining HTML & CSS

Page 59: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title>

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 60: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

<!DOCTYPE html><html>

<head><title>Title!</title><link rel="stylesheet"

type="text/css"href="style.css">

</head><body><h1>Heading!</h1><p>Paragraph!</p>

</body></html>

hello.html

Page 61: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

CSS Workshop

Workshop: go.6148.io/cssSlides: go.6148.io/html

Page 62: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 1Open packing_list.htmlin your text editor

Add an unordered list with some items you might need to embark on your journey of finding Sonde.

Page 63: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

CSS Time!!Don’t edit your HTML file anymore.

Open styles.css.

Page 64: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

CSS Time!!Don’t edit your HTML file anymore.

Open styles.css.

Page 65: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 2CSS Warmup:

Change the color of the packing list to your favorite color

Page 66: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 2CSS Warmup:

Change the color of the packing list to your favorite color

Change it to #777

Page 67: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

displayThe display property specifies how an element is displayed.

display: none

display: block

display: inline

display: inline-block

Page 68: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

display: blockBlock level elements always start on a new line and take the full width available by default. You can set width and height of block elements.

Examples of block level elements:

<div><h1>…<h6><p>

Page 69: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

style.css

<h1>Heading!</h1><p>Paragraph!</p>

hello.html

Heading!Paragraph!

Page 70: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

h1 {background-color: gray;

}

p {background-color: #ECCEA1;

}

style.css

<h1>Heading!</h1><p>Paragraph!</p>

hello.html

Heading!Paragraph!

Page 71: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

display: inlineInline elements do not start on a new line and only takes up as much width as necessary

Examples of inline elements:

<a><img><span>

Page 72: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

display: inline-blockInline-block elements do not start on a new line but also have a width and a height

img {display: inline-block;

}

Page 73: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 3Change the display of the list items to be block and then inline-block.

Page 74: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 4Give the area surrounding the list items a border and a background color. Try making it red, or dashed, or very thick.

div {border: solid black 1px;

}style color width

Page 75: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 4Give the area surrounding the list items a border and a background color. Try making it red, or dashed, or very thick.

Google how to round the corners of an element and give it a background color.

Make a solid border 1px thick with color #e7e7e7. Make the background color #f8f8f8 and the corners radius 4px.

Page 76: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 5When the user hovers over a list item, change the color of the background and the text.

Page 77: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 5When the user hovers over a list item, change the color of the background and the text.

The color of the background should become #e7e7e7 and the color of the text should become #555.

Page 78: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 6Make the area around the list areas bigger, keeping the background color on hover like this:

Page 79: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

CSS Box ModelMARGIN

BORDER

PADDING

CONTENT

Page 80: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 6Make the area around the list areas bigger, keeping the background color on hover filling up the entire menu.

MARGINBORDER

PADDING

CONTENT

Page 81: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Exercise 7Get rid of the extra space at the end of the menu and then center the menu in the window.

Page 82: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Position, float, z-index

Advanced Topics

Page 83: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Position, float, z-index

Advanced Topics

Page 84: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Position, float, z-index

Advanced Topics

Page 85: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Cascading and specificity

Advanced Topics

#unique {color: red;

}.info {

color: blue;}p {

color: purple;}

style.css

<p id="unique"class="info">

Info</p>

hello.html

Page 86: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Flexbox

Advanced Topics

Page 87: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

Media Queries

Advanced Topics

@media (min-width: 900px) {p {

color: red;}

}

Page 88: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

CSS frameworks/libraries (Bootstrap, Foundation, Semantic UI)

Advanced Topics

Page 89: HTML CSS - Massachusetts Institute of Technology6.148.scripts.mit.edu/.../pages/lectures/WEBday2_htmlcss.pdf · 2017-01-10 · CSS frameworks/libraries (Bootstrap, Foundation, Semantic

LUNCH!

JavaScript workshop

jQuery Workshop

Up Next...