html css - webdevelopment.mit.eduwebdevelopment.mit.edu/2017/pages/lectures/webday2_htmlcss.pdf ·...
TRANSCRIPT
HTMLHypertext Markup Language
The language your web browser uses to describe the content and structure on web pages
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body>
<h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
Basic HTML ElementsRoot of HTML DocumentInfo about DocumentDocument BodyHeader tagsParagraph tags
<html><head><body><h1>, <h2>, <h3>, …<p>
Inserting Images
app/hello.htmlimages/
pusheen.gif
<img src="pusheen.gif"><img src="images/pusheen.gif">
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><ul>
<li>Item 1</li></ul>
</body></html>
hello.html
• Item 1
<!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
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><div>
<h1>Heading!</h1><p>Paragraph!</p>
</div> </body>
</html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><div>
<h1>Heading!</h1><p>Paragraph!</p>
</div> </body>
</html>
hello.html
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
HeadingParagraph!
HeadingParagraph!
Info
<h1>Heading!</h1><p>Paragraph!</p><p>Info</p>
hello.html
p {color: red;font-family: Arial;font-size: 24pt;
}
style.css
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
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
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
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
<!DOCTYPE html><html>
<head><title>Title!</title>
</head><body><h1>Heading!</h1><p>Paragraph!</p>
</body></html>
hello.html
<!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
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.
displayThe display property specifies how an element is displayed.
display: none
display: block
display: inline
display: inline-block
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>
h1 {background-color: gray;
}
p {background-color: #ECCEA1;
}
style.css
<h1>Heading!</h1><p>Paragraph!</p>
hello.html
Heading!Paragraph!
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>
display: inline-blockInline-block elements do not start on a new line but also have a width and a height
img {display: inline-block;
}
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
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.
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.
Exercise 6Make the area around the list areas bigger, keeping the background color on hover like this:
Exercise 6Make the area around the list areas bigger, keeping the background color on hover filling up the entire menu.
MARGINBORDER
PADDING
CONTENT
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