DOM: Document Object Model. What are trees? Or more like this…

19
DOM: Document Object Model

Transcript of DOM: Document Object Model. What are trees? Or more like this…

Page 1: DOM: Document Object Model. What are trees? Or more like this…

DOM:Document

Object Model

Page 2: DOM: Document Object Model. What are trees? Or more like this…

What are trees?

Page 3: DOM: Document Object Model. What are trees? Or more like this…

Or more like this…

Page 4: DOM: Document Object Model. What are trees? Or more like this…

A Better ExampleSam & Bessie

Al & Jewel Paul & Dawn

Leo & Bea

Peter &

Cate

Mark &

Dina

Abby &

Phil

Tess &

John

Barb &

Ray

Kari & Hal

Dan &

Cora

Stu & Chi

Sue

Leah LoriMary Jen AndyAl Noah

BenJake

Amy Sara Moe AndyDi Lady

Page 5: DOM: Document Object Model. What are trees? Or more like this…

DescendentsSam & Bessie

Al & Jewel Paul & Dawn

Leo & Bea

Peter &

Cate

Mark &

Dina

Abby &

Phil

Tess &

John

Barb &

Ray

Kari & Hal

Dan &

Cora

Stu & Chi

Sue

Leah LoriMary Jen AndyAl Noah

BenJake

Amy Sara Moe AndyDi Lady

Page 6: DOM: Document Object Model. What are trees? Or more like this…

ChildrenSam & Bessie

Al & Jewel Paul & Dawn

Leo & Bea

Peter &

Cate

Mark &

Dina

Abby &

Phil

Tess &

John

Barb &

Ray

Kari & Hal

Dan &

Cora

Stu & Chi

Sue

Leah LoriMary Jen AndyAl Noah

BenJake

Amy Sara Moe AndyDi Lady

Page 7: DOM: Document Object Model. What are trees? Or more like this…

ChildrenSam & Bessie

Al & Jewel Paul & Dawn

Leo & Bea

Peter &

Cate

Mark &

Dina

Abby &

Phil

Tess &

John

Barb &

Ray

Kari & Hal

Dan &

Cora

Stu & Chi

Sue

Leah LoriMary Jen Andy Noah

BenJake

Amy Sara Moe AndyDi Lady

Al

Page 8: DOM: Document Object Model. What are trees? Or more like this…

SiblingsSam & Bessie

Al & Jewel Paul & Dawn

Leo & Bea

Peter &

Cate

Mark &

Dina

Abby &

Phil

Tess &

John

Barb &

Ray

Kari & Hal

Dan &

Cora

Stu & Chi

Sue

Leah LoriMary Jen AndyAl Noah

BenJake

Amy Sara Moe AndyDi Lady

Page 9: DOM: Document Object Model. What are trees? Or more like this…

HTML Creates a tree: DOM

HTML tags create a treeCalled the DOM

(Document Object Model)

Page 10: DOM: Document Object Model. What are trees? Or more like this…

HTMLbody

div footerheader

h1 section

ul p tablediv p figureul

li pli tr trp li divli

td td td tdtd td

Page 11: DOM: Document Object Model. What are trees? Or more like this…

HTMLbody

div footerheader

h1 section

ul p tablediv p figureul

li pli tr trp li divli

td td td tdtd td

siblings

child

Page 12: DOM: Document Object Model. What are trees? Or more like this…

Using the DOM

CSS will allow us to format selectively based on the tree

Page 13: DOM: Document Object Model. What are trees? Or more like this…

CSS Selectors context tag {

Applies to any tag inside context

Space is a descendant selector

context > tag { Applies to any tag directly inside context

> is a child selector

Context + tag { Applies only to a tag that DIRECTLY FOLLOWS a

context

+ is an adjacent sibling selector

Page 14: DOM: Document Object Model. What are trees? Or more like this…

HTMLbody

div footerheader

h1 section

ul p tablediv p figureul

li pli tr trp li divli

td td td tdtd td

Page 15: DOM: Document Object Model. What are trees? Or more like this…

Child pseudo elements

W3schools

first-child, last-child, nth-child(), nth-last-child()

() options:

Number

Even-odd

Formula

Every 3rd would be 3n+0

4, 7, 11 would be 3n+1

nth-last-child counts from end

Page 16: DOM: Document Object Model. What are trees? Or more like this…

CSS Inheritence

If you have 2 entries in your CSS:

div {}

div.class {}

BOTH are applied to <div class=“class”>

Taking advantage: “all my divs will have a border”

Problems: widths can conflict and rules aren’t obvious

Page 17: DOM: Document Object Model. What are trees? Or more like this…

Excel tables to the web

Page 18: DOM: Document Object Model. What are trees? Or more like this…

Getting Tables to the Web

Tableizer

No classes

Not formatted

We have had Mac problems

HTML Formatter

Page 19: DOM: Document Object Model. What are trees? Or more like this…

Getting Tables to the Web

Mr. Data Converter

Sets up classes

Formatted

Caveat: it requires that there be a value in the upper left cell