Document Object Model. Overview

Similar documents
HTML. HTML Evolution

1/6/ :28 AM Approved New Course (First Version) CS 50A Course Outline as of Fall 2014

Website Development with HTML5, CSS and Bootstrap

CS144 Notes: Web Standards

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

Summary 4/5. (contains info about the html)

Web Site Development with HTML/JavaScrip

Text and Layout. Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 11. This presentation 2004, MacAvon Media Productions

Web development using PHP & MySQL with HTML5, CSS, JavaScript

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

Markup Language. Made up of elements Elements create a document tree

CHAPTER 2 MARKUP LANGUAGES: XHTML 1.0

Certified HTML5 Developer VS-1029

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

Chapter 2:- Introduction to XHTML. Compiled By:- Sanjay Patel Assistant Professor, SVBIT.

Html basics Course Outline

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

Programmazione Web a.a. 2017/2018 HTML5

CSC Web Technologies, Spring HTML Review

Static Webpage Development

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

HTML TAG SUMMARY HTML REFERENCE 18 TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES MOST TAGS

CSI 3140 WWW Structures, Techniques and Standards. Markup Languages: XHTML 1.0

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

Understanding this structure is pretty straightforward, but nonetheless crucial to working with HTML, CSS, and JavaScript.

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

Certified HTML Designer VS-1027

HTML and CSS COURSE SYLLABUS

A Brief Introduction to HTML

Deccansoft Software Services

Review of HTML. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar

HyperText Markup Language (HTML)

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Index. CSS directive, # (octothorpe), intrapage links, 26

GRAPHIC WEB DESIGNER PROGRAM

CSCB20 Week 6. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2016

Hyper Text Markup Language HTML: A Tutorial

To link to an external stylesheet, the link element is placed within the head of the html page:

Create web pages in HTML with a text editor, following the rules of XHTML syntax and using appropriate HTML tags Create a web page that includes

QUICK REFERENCE GUIDE

Data Visualization (CIS/DSC 468)

CS/COE 1520

Web Development & Design Foundations with XHTML. Chapter 2 Key Concepts

The [HTML] Element p. 61 The [HEAD] Element p. 62 The [TITLE] Element p. 63 The [BODY] Element p. 66 HTML Elements p. 66 Core Attributes p.

introduction to XHTML

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

HTML CS 4640 Programming Languages for Web Applications

WML2.0 TUTORIAL. The XHTML Basic defined by the W3C is a proper subset of XHTML, which is a reformulation of HTML in XML.

1.264 Lecture 12. HTML Introduction to FrontPage

COPYRIGHTED MATERIAL. Contents. Introduction. Chapter 1: Structuring Documents for the Web 1

Web Development and HTML. Shan-Hung Wu CS, NTHU

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Introduction to Web Technologies

CS109 Data Science Data Munging

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Tutorial 1 Getting Started with HTML5. HTML, CSS, and Dynamic HTML 5 TH EDITION

Web and Apps 1) HTML - CSS

Introduction to WEB PROGRAMMING

MODULE 2 HTML 5 FUNDAMENTALS. HyperText. > Douglas Engelbart ( )

CSS.

Chapter 3 Style Sheets: CSS

Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

Web Engineering CSS. By Assistant Prof Malik M Ali

Cascading Style Sheet

CSC 121 Computers and Scientific Thinking

First Name Last Name CS-081 March 23, 2010 Midterm Exam

Final Exam Study Guide

HTML. MPRI : Web Data Management. Antoine Amarilli Friday, December 7th 1/28

CSC Web Programming. Introduction to HTML

MPT Web Design. Week 1: Introduction to HTML and Web Design

Announcements. Paper due this Wednesday

Introduction to using HTML to design webpages

Web Development & Design Foundations with HTML5 & CSS3 Instructor Materials Chapter 2 Test Bank

A HTML document has two sections 1) HEAD section and 2) BODY section A HTML file is saved with.html or.htm extension

XHTML & CSS CASCADING STYLE SHEETS

Ministry of Higher Education and Scientific Research

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 1

Selected Sections of Applied Informatics

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)

Cascading Style Sheets

Shankersinh Vaghela Bapu Institue of Technology

HTML HTML/XHTML HTML / XHTML HTML HTML: XHTML: (extensible HTML) Loose syntax Few syntactic rules: not enforced by HTML processors.

AIM. 10 September

Fundamentals: Client/Server

NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS

week8 Tommy MacWilliam week8 October 31, 2011

Basics of Web Design, 3 rd Edition Instructor Materials Chapter 2 Test Bank

CSS: Cascading Style Sheets

B. V. Patel Institute of Business Management, Computer & Information Technology, UTU

2.1 Origins and Evolution of HTML

COMP519 Web Programming Lecture 3: HTML (HTLM5 Elements: Part 1) Handouts

S. Rinzivillo DATA VISUALIZATION AND VISUAL ANALYTICS

COMS 359: Interactive Media

Kurdistan Regional Government Iraq Ministry of Higher Education and Scientific Research, Duhok Polytechnic University

ADOBE VISUAL COMMUNICATION USING DREAMWEAVER CS5 Curriculum/Certification Mapping in MyGraphicsLab

More about HTML. Digging in a little deeper

What is a web site? Web editors Introduction to HTML (Hyper Text Markup Language)

INTRODUCTION TO HTML5! HTML5 Page Structure!

Transcription:

Overview The (DOM) is a programming interface for HTML or XML documents. Models document as a tree of nodes. Nodes can contain text and other nodes. Nodes can have attributes which include style and behavior attributes. Possible to get all nodes of a particular type, specic class or id.

HTML Overview HTML stands for HyperText Markup Language. Structured text with explicit markup denoted within < and > delimiters. Not what-you-see-is-what-you-get (WYSIWYG) like MS word. Similar to other text markup languages like latex.

HTML Evolution HTML derived from IBM's Standard Generalized Markup Language SGML. HTML 1.0; uses href for hyperlinks. Support for tables, client-side image maps. Support for presentation elements like font, color. Modern HTML removes support for presentation elements; moved presentation into CSS. HTML documents are often sloppily marked up; standards explicitly dene behavior for some bad mark up.

HTML DTD's HTML 4.0 Never caught on. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/tr/html4/strict.dtd"> XHTML HTML as an XML document. Since XML must be well-formed, diculties for web authors who were used to sloppy markup. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/ xhtml1-strict.dtd"> HTML 5 Modern HTML, simple DTD <!DOCTYPE html>.

HTML Markup A HTML document consists of a tree of HTML elements. A HTML element delimited between a start tag like <a> and an end-tag like </a>. There may be text or other tags between the start tag and end tag. The start tag may contain attributes, like <a href="submit.cgi">. Any element can have attributes with names starting with data-. Allows extensible attributes. A tag with no content can be denoted as <br />; often simply use opening tag without closing tag; so simply <br>.

Common HTML Attributes href id class Species absolute or relative URL to another resource. Species an ID for element. The ID must be unique across the entire document. Value consists of multiple space-separated identiers. Element class can be used for attaching styling and/or behavior to the element.

Page-Level HTML Elements <html> <head> <body> A single <html> element must be present enclosing entire content. Contains meta-content like <title> (displays title in browser window bar), <link> for loading CSS stylesheets, <script> for loading JavaScript les. Encloses actual document content.

Block-Level Markup <h1>,..., <h6> <section> <nav> <div> <p> Headings at dierent levels. Delimits a section of the document. Usually followed by a <hi> element. Used for delimiting content used for site navigation. Used for delimiting general block content. Usually used to attach style or behavior to a block using id or class attributes. Used for delimiting paragraphs.

List Markup Unordered Lists Denoted using <ul> <li>...</li>... </ul> Ordered Lists Denoted using <ol> <li>...</li>... </ol> Denition Lists Denoted using <dl> <dt>...</dt> <dd>...</dd>... </dl>

Table Markup Tables delimited using <table> tags. Rows within a table are delimited using <tr> tags. Table entries within a row are delimited using <th> tags (for heading entries) or <td> tags (for data entries). A table entry can span multiple columns (using attribute colspan) or multiple rows (using attribute rowspan).

Inline Markup <span> <em> <strong> <img> Simply used to delimit some content, similar to <div>. Example <span class="keyword">while</span>. Emphasized text. Example: <em>important</em>. Strongly emphasized text. Example: <strong class="alert">warning</strong> Used to embed an image Example: <img src="smile-emoji.gif">. Can also be used at the block level. <a> Hyperlinks. Example See <a href="other-doc.html>other document</a>.

Linking to Stylesheets <link rel="stylesheet" href="style.css"> End tag must not be present. For best eciency, include in head section.

Linking to JavaScript <script type="text/javascript" src="code.js"></script> End tag must be present. For best eciency, include after bulk of document body just before </body> tag.

Forms <form action="http:www.google.com" method="get"> Search: <input name="q"> </form> Forms need to be set up using <form> tags. action gives URI where form should be submitted. method can be get (default) or post. Other HTTP methods are not supported. enctype used when method is post. Default is application/x-www-form-urlencoded. Use multipart/form-data if uploading les. HTML5 allows text/plain.

Form Controls All form controls have a name attribute which gives the name by which that control is submitted. Usually form controls have to be embedded within a <form> element, but HTML5 allows using a form attribute specifying the id of any <form> element on that page. Form controls can be disabled which makes them inactive. Captions for form controls by putting control inside a <label> element or by specifying control id in the for attribute for <label>. Can group controls together using <fieldset>.

Form Input Control <input type=" =TYPE"> Live example Main form input eld. TYPE traditionally had values button, checkbox, file, hidden, image, password, radio, reset, submit, text (default). HTML5 added many more variants: color for color-picker, date, datetime-local, time, month, week for date-time, email, tel for contact information, number, range for numeric information, url for URLs. autocomplete attribute allows browser to ll in information previously saved by user. pattern attribute is a regex the entire value is matched against.

Miscellaneous Form Controls <select> <textarea> Provides a menu of options using embedded <option> elements. Specify multiple attribute to allow multiple options to be selected. Can make an option selected by setting its selected attribute. Multiline text input.

API to access parsed HTML/XML documents. Can be used from any language, but in browsers the only language commonly supported currently is JavaScript. Datatypes include document, element, attribute.

Document Current document available as document property of global window object. Properties include location (URL, giving href, protocol, hostname, port, pathname, search, hash), contenttype, body, cookie (cookie defs separated by ;). Methods include getelementsbyname(), getelementbyid(), getelementsbyclassname(). Allows updating document content dynamically Dynamic HTML (DHTML).

Element Represents an individual HTML element. Properties include id, classlist, innerhtml (markup within element), attributes (map NamedNodeMap of attributes). Methods include getattribute(), getattributenames(), removeattribute(), setattribute().

Stylesheets Current best practice is to relegate presentation to stylesheets. Can be specied using external stylesheets, using <link> elements. Can also be specied using internal stylesheets using <style> elements. Can also be specied inline for an individual element using style attribute. Precedence (in descending order) inline, internal, external.

Cascading Style Sheets Cascading Style Sheets (CSS) species priority rules (cascade) between dierent style declarations which may apply to a element. A CSS stylesheet consists of a set of rules. A rule consists of a selector followed by a brace delimited set of CSS declarations separated by ;. p.highlight { background-color: yellow; color: blue } Will not cover CSS declarations.

Simple CSS Selectors Universal Selector * selects all elements; usually used in conjunction with other selectors. HTML Element Names Simply specify name of HTML element. Examples p, a, table. Class Selectors Name of class preceeded by a.. Examples.highlight,.important. ID Selectors [attr] ID of element preceeded by #. Examples include #form1, #table1. Note that ID must be unique in document. Selects all elements having attribute attr. Examples [href],

Combining Selectors Constrain Descendent Child Can follow selector by class or id selectors (without spaces). p.chemical matches p elements having class chemical. Simply write selectors adjacent to each other separated by a space. Example:.chemical p selects all p elements which are descendents of a element which has class chemical. Write selectors separated by a >. Example:.chemical > p selects all p elements which are direct children of a element which has class chemical.

Combining Selectors Continued Sibling Write selectors separated by a ~. Example:.chemical ~ p selects all p elements which follow (not necessarily immediately) a element which has class chemical. Adjacent Sibling Write selectors separated by a +. Example:.chemical + p selects all p elements which immediately follow a element which has class chemical.

Unobstrusive JavaScript Dierent technologies used for dierent concerns: Content HTML used for content. Presentation CSS used for styling. Behavior JavaScript used to specify behavior. Do not mix technologies. Best practice is to spit out into separate *.html, *.css and *.js les. Modern technology blurs lines between concerns; CSS 3 contains support for visual behavior traditionally achieved using JavaScript. Nevertheless it remains a good organizational principle.

Bad Code In doc.html: <a href="submit.cgi" onclick="checkform(this)" style="font-weight: bold"> Submit </a> Uses CSS and JavaScript code within attributes of HTML elements. Maintaining le will require content, presentational and programming skills.

Better Code 1 In doc.html maintained by content specialist or a Content Management System (CMS):`<a href="submit.cgi" id="submit">submit</a>`. 2 In doc.css maintained by web designer #submit { font-weight: bold; }. 3 In doc.js maintained by front-end programmer: document. getelementbyid('submit').onclick(checkform(this)). Separate concerns, separate les, separate specialists. doc.html will need to reference doc.css stylesheet and doc.js. In practice, single.css stylesheet,.js le shared by multiple html documents.