Markup Languages and HTML5
Total Page:16
File Type:pdf, Size:1020Kb
Web Technologies VU (706.704) Vedran Sabol ISDS, TU Graz Oct 19, 2020 Vedran Sabol (ISDS, TU Graz) Web Technologies Oct 19, 2020 1 / 71 Outline 1 Markup Languages 2 Web Standards Model 3 Introduction to HTML5 4 General Markup Changes 5 Forms Markup Changes 6 Graphics with Canvas Vedran Sabol (ISDS, TU Graz) Web Technologies Oct 19, 2020 2 / 71 HTML5 - Part I Web Technologies (706.704) Vedran Sabol ISDS, TU Graz Oct 19, 2020 Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 3 / 71 Markup Languages Markup Languages Markup: additional information, how to interpret the text in a document In all text-processing applications Typically, invisible to the user E.g. in LaTeX: \section{title of section} In HTML: <p>new paragraph, blabla...</p> Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 4 / 71 Markup Languages Structure Structure defined as nested elements Element: tags, attributes, content Tags: start tag + end tag Attributes: inside start tag Content: Text + sub-elements Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 5 / 71 Markup Languages Generalized/Descriptive Markup Describe structure of documents only Presentation and/or behavior of documents defined elsewhere Separate content (structure) from presentation and/or behavior This principle has a number of advantages Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 6 / 71 Markup Languages Advantages Code efficiency: smaller files by separating content, presentation and behavior Presentation and behavior files stored separately and only once No overhead in markup files, saves network bandwidth Change them at a single place for all markup files Ease of maintenance and consistency in presentation and behavior Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 7 / 71 Markup Languages Advantages Device compatibility Easy to apply alternative presentations and behavior, e.g. handheld devices Web crawlers/robots: documents contain only markup and content No information that is hard for robots to crawl and parse Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 8 / 71 Markup Languages Standardized General Markup Language SGML: quite old ISO standard ISO8879 (1986) Meta - markup language: define other markup languages with it Does not define the markup, only provide the means to define it Defines the basic syntax How to distinguish content from markup (elements, attributes, entities) Interpration and semantics is defined by the processing application Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 9 / 71 Markup Languages Standardized General Markup Language Elements (nested) describe the structure of a document Element is delimited with a start-tag and an end-tag end-tag is not obligatory :-( Attributes describe properties associated with elements Entities: asociate a string with either a unique alias or reserverd words SGML based on ASCII: binary data and special characters coded as entities Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 10 / 71 Markup Languages Standardized General Markup Language Document type definition (DTD) file defines the markup Which elements are allowed, required, and how they are nested Which attributes an element may/must have The application understands the markup and knows what to do with it Syntactical check against the basic SGML syntax and the specific DTD syntax Well-formed document (markup-syntax only) vs. valid document (DTD) Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 11 / 71 Markup Languages Standardized General Markup Language Problems of SGML: Very complex, specification with 500+ pages In addition to that the DTD Omission of end-tags: hard for parsers Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 12 / 71 Markup Languages eXtensible Markup Language XML: a new meta-markup language (does not define tag semantics) Approx. 50 pages specification, easier to use :) Cleaner syntax, easier to write parsers Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 13 / 71 Markup Languages eXtensible Markup Language Required: end-tags, quotation marks with attributes, correct nesting If a markup does not have content: empty-tag (e.g. <empty/>) Names are case-sensitive XML strictly separates the content, presentation and behavior: need additional technologies for that Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 14 / 71 Markup Languages HyperText Markup Language The most well-known SGML DTD 1990 Tim Berners-Lee used an SGML DTD Added images, links, and created HTML DTD Original idea: a simple DTD, separation of content, presentation and behavior Application created to understand the HTML DTD: browser! Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 15 / 71 Markup Languages HyperText Markup Language Standardisation efforts by Web Consortium W3C: HTML 4.01 W3C recommendation since 1999 Problems creating a standard: \Browser Wars" (Netscape vs. Microsoft) Adding presentation specific tags (font, colors, center ...) Adding different scripting languages for behavior Mixture of presentation, behavior and content Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 16 / 71 Markup Languages (X)HTML eXtensible HyperText Markup Language (XHTML) http://www.w3.org/TR/xhtml1/ XHTML is redefinition of HTML in XML HTML 4.01 reformulated as an XML DTD (insted of SGML DTD) Decomposition into a number of modules Module is a set of elements used for the same purpose Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 17 / 71 Markup Languages (X)HTML Structure module: body, head, html, title Text module: headings, div, span, etc, Hypertext module: a Table module: table, tr, td, etc. Each module defined with an XML DTD Purpose: create an XHTML dialect by combining needed modules Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 18 / 71 Markup Languages Markdown XML criticized for verbosity (and complexity) Markdown language was created in 2004 Very easy to read and write plain text format Text-to-HTML conversion tool converts markdown to structurally valid XHTML or HTML Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 19 / 71 Web Standards Model Web Standards Model Web Consortium defines the Web Standards Model (X)HTML: markup Cascading Style Sheets (CSS): presentation/styles Javascript: behavior Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 20 / 71 Web Standards Model CSS Better control for formatting and layout of HTML elements Browsers implement default presentation, can be altered by CSS You can influence formats, fonts, colors, text alignment, spacings, positioning ... Specify in an external document - advantages of separating content and presentation Specifications (approved by W3C): CSS1 and CSS2 (completed), CSS3 (in development, divided into modules) Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 21 / 71 Web Standards Model Javascript JavaScript (JS) is an interpreted programming language (1995) Formalized in the ECMAScript standard since 1997, latest version is 10 (June 2019) JS embedded in HTML code or using external Javascript files External files: separation of content and behavior Works on the Document Object Model (DOM) Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 22 / 71 Introduction to HTML5 HTML development HTML5 is the next major revision of the HTML standard W3C Recommendation (since October 2014) The Web Hypertext Application Technology Working Group (WHATWG) started work on the specification in 2004 The group consisted of industry players - mainly browser vendors XHTML2 group developed further XHTML standard at W3C 2009 W3C stopped the work on XHTML2 and joined HTML Working group Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 23 / 71 Introduction to HTML5 HTML5 development Web Hypertext Application Technology Working Group (WHATWG) HTML Living Standard World Wide Web Consortium (W3C) Main international standards organization for WWW HTML5 first draft in 2007 Stable HTML5 Recommendation released in October 2014 5.2 Recommendation in 2017 Development on 5.3, first draft in 2017 W3C authority on HTML and DOM to WHATWG (May 2019) WHATWG's HTML Living Standard is now authoritative! Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 24 / 71 Introduction to HTML5 HTML5 Overview HTML5 is not only hypertext markup language It is a collection of various Web technologies Markup part Presentation part (CSS3) Behavior (Javascript) Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 25 / 71 Introduction to HTML5 HTML5 Overview HTML5 introduces new elements reflecting typical usage of websites E.g. replaces generic div and span elements with navigation and footer elements The canvas element for 2D drawing Ability to use inline SVG and MathML in text/html Multimedia elements such as audio and video for media playback Deprecated elements (e.g. font) removed - use CSS instead Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 26 / 71 Introduction to HTML5 HTML5 Overview Emphasis on DOM scripting Adjusted and new APIs for DOM scripting Browser history management Offline web applications (cacheing, local storage) Various storage mechanisms: Web SQL, File API, Indexed DB (key-value store) Drag-and-drop support Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 27 / 71 Introduction to HTML5 HTML5 Overview Microdata: nesting semantic metadata within content Geolocation API Backgroud threads: Web Workers Full duplex client-server communication: Web Sockets Cross-document messaging mechanisms Vedran Sabol (ISDS, TU Graz) HTML5 - Part I Oct 19, 2020 28 / 71 General Markup Changes General markup changes HTML5 is not