Introduction to HTML - University of California, Los...

55
Introduction to HTML

Transcript of Introduction to HTML - University of California, Los...

Page 1: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Introduction to HTML

Page 2: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

TOOLS

Page 4: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s
Page 5: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

HTML

Page 6: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Hyper-Text Markup Language

Page 7: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Tag

Page 8: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Tag

<html>

angle brackets (aka greater-than and less-than)

Page 9: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Tag

<html>

name

Page 10: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Tag

<p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </p>

opening and closing

Page 11: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Tag

<p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </p>

opening and closing

Page 12: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Tag

<p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </p>

content

Page 13: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Tag

<p> <strong>Lorem</strong> ipsum dolor sit amet, consect elit. </p>

Tags can contain other tags.

Page 14: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Document

Page 15: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Document

<!doctype html> <html lang="en"> <head> <title>Document</title> </head> <body> </body> </html>

Page 16: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The Document

<!doctype html> <html lang="en"> <head> <title>Document</title> </head> <body> </body> </html>

everything goes here in the body tag

Page 17: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Structural Elements

Page 18: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Header

<header> <h1>Super Website</h1> <h2>By Chandler</h2> </header>

Page 19: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Content for the top of a page or major section. Includes things like title, navigation, masthead, etc.

Header

Page 20: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Header

Page 21: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Headers

<h1>REALLY IMPORTANT</h1> <h2>Pretty Important</h2>

<h3>I’m important too!</h3> <h4>Meh, so so</h4>

<h5>I’m not too useful</h5> <h6>Neither am I</h6>

Page 22: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The numbers in a header tag indicate relative importance, NOT the number of this item on the page, i.e. <h3> is the third most important thing, not the third thing.

Headers

Page 23: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

You can have multiples of each header tag on the same page. Think of book chapters, each chapter has the same relative importance, so they would all have the same level of header tag.

Headers

Page 24: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Footer

<footer> <p>All content owned by me</p> </footer>

Page 25: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Content at the bottom of a page or major section. Includes things like copyright, site map, etc.

Footer

Page 26: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Footer

Page 27: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Nav

<nav> <a href=“…">A Page</a> <a href=“…">Another Page</a> </nav>

Page 28: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links.

Nav

Page 29: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Nav

Page 30: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

OthersHTML5 introduced a number of tags to help you group content together. When each is appropriate is still hard to determine, but they are there for you and sometimes handy.

Page 31: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Section<section> … </section>

“The section element represents a generic document or application section…A general rule is that the section element is appropriate only if the element’s contents would be listed explicitly in the document’s outline.”

Page 32: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Article<article> … </article>

“The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site… This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.”

Page 33: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Aside<aside> … </aside>

“With aside, it’s crucial to remain aware of its context. When used within an article element, the contents should be specifically related to that article (e.g., a glossary). When used outside of an article element, the contents should be related to the site (e.g., a blogroll, groups of additional navigation, and even advertising if that content is related to the page).”

Page 34: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Div<div> … </div>

Div is the primary workhorse for styling and grouping content. Unlike the other section elements, it has no semantic meaning at all, no rules, just a simple container for stuff making it ideal for cases when a specific container tag won’t work.

Page 35: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Paragraphs

<p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec felis, ultricies nec, pellentesque eu, pretium quis, sem. </p>

Page 36: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Whitespace (tabs, spaces) is ignored. Or more accurately, all white space collapses into a single space.

Whitespace

Page 37: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Hypertext

Page 38: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Hypertext is the first “ht” in “http” which stands for hypertext transfer protocol.

Hypertext

Page 39: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Anchor (link) Tags

<a href=“http://wikileaks.org”>Wikileaks</a>

attributes are values defined in the opening tag

Page 40: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Anchor (link) Tags

<a href=“http://wikileaks.org”>Wikileaks</a>

for anchor tags, use the “href” attribute to define the target of the link

Page 41: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Images

Page 42: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Img Tags

<img src="kitten.jpg" alt="a kitten">

the src attribute defines the path to the image

Page 43: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Img Tags

<img src="kitten.jpg" alt="a kitten">

the alt attribute provides a text description of the image

Page 44: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Images

Images should be in JPEG, GIF, or PNG format.

Page 45: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Images

Page 46: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

File Paths and File Names

Page 47: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

“Fully Qualified URL”

<a href="http://foo.com">

Page 48: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

“Fully Qualified URL”

<a href="http://foo.com">

Includes the “http://”

Page 49: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Relative File Paths

<img src="foo.jpg">

Page 50: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Relative File Paths

<img src="foo.jpg">

Looks for the file in the same folder as the current one

Page 51: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Case Matters!

<img src="foo.jpg">

Is not the same as

<img src="Foo.jpg">

Page 52: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Case Matters!

<img src="foo.jpg">

Will not work with a file named Foo.jpg

Page 53: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Case Matters!

Always name your files with lower case letters, and replace spaces with -

Page 54: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

Case Matters!

becomes

My Awesome Photo.jpg

my-awesome-photo.jpg

Page 55: Introduction to HTML - University of California, Los Angelesclasses.dma.ucla.edu/Spring15/161/content/notes/4-HTML.pdf · Aside  …  “With aside, it’s

index.html

The main file of your site, the first page that people will see, for every website you ever make should be

named “index.html” always, forever.