HTML. HTML is now very well standardized, but sites are still not getting it right. HTML tags adaptation

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

Wireframe :: tistory wireframe tistory.

Certified HTML5 Developer VS-1029

CPET 499/ITC 250 Web Systems. Topics

Introduction to HTML5

HTML+ CSS PRINCIPLES. Getting started with web design the right way

HTML CS 4640 Programming Languages for Web Applications

INTRODUCTION TO HTML5! HTML5 Page Structure!

Programmazione Web a.a. 2017/2018 HTML5

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

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

Learning Objectives. Review html Learn to write a basic webpage in html Understand what the basic building blocks of html are

HTML: Parsing Library

HTML: Parsing Library

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

introduction to XHTML

What is XHTML? XHTML is the language used to create and organize a web page:

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

Browsers form the Web's user interface, with web versions of everything graphical. Browsers Tag Soup HTML Development

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

HyperText Markup Language (HTML)

How the Internet Works

CS144 Notes: Web Standards

HTML. HTML Evolution

HTML Overview. With an emphasis on XHTML

Announcements. 1. Class webpage: Have you been reading the announcements? Lecture slides and coding examples will be posted

QUICK REFERENCE GUIDE

Web Programming Week 2 Semester Byron Fisher 2018

HTML5 & CSS 8 th Edition. Chapter 2 Building a Webpage Template with HTML5

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.

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

Scripting for Multimedia LECTURE 1: INTRODUCING HTML5

Programming of web-based systems Introduction to HTML5

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

Styles, Style Sheets, the Box Model and Liquid Layout

HTML Hyper Text Markup Language

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

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

Tutorial 2 - HTML basics

Announcements. Paper due this Wednesday

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

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

CHAPTER 2 MARKUP LANGUAGES: XHTML 1.0

CSC Web Programming. Introduction to HTML

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

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

Full file at New Perspectives on HTML and CSS 6 th Edition Instructor s Manual 1 of 13. HTML and CSS

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

Designing UI. Mine mine-cetinkaya-rundel

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

Cascading Style Sheet

Certified HTML Designer VS-1027

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

c122sep814.notebook September 08, 2014 All assignments should be sent to Backup please send a cc to this address

XML is a popular multi-language system, and XHTML depends on it. XML details languages

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

c122jan2714.notebook January 27, 2014

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

HTML HTML. Chris Seddon CRS Enterprises Ltd 1

BASICS OF WEB DESIGN CHAPTER 2 HTML BASICS KEY CONCEPTS

History of the Internet. The Internet - A Huge Virtual Network. Global Information Infrastructure. Client Server Network Connectivity

Document Object Model. Overview

Internet publishing HTML (XHTML) language. Petr Zámostný room: A-72a phone.:

INTRODUCTION TO WEB USING HTML What is HTML?

Title: Sep 12 10:58 AM (1 of 38)

Inline Elements Karl Kasischke WCC INP 150 Winter

Implementing a chat button on TECHNICAL PAPER

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

Oliver Pott HTML XML. new reference. Markt+Technik Verlag

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

Week 1 - Overview of HTML and Introduction to JavaScript

Brief Intro to HTML. CITS3403 Agile Web Development. 2018, Semester 1

CMPT 165 Unit 2 Markup Part 2

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

By Ryan Stevenson. Guidebook #2 HTML

ROLE OF WEB BROWSING LAYOUT ENGINE EVALUATION IN DEVELOPMENT

XHTML & CSS CASCADING STYLE SHEETS

Vebra Search Integration Guide

Evaluation of alignment methods for HTML parallel text 1

Web Designing HTML5 NOTES

11. HTML5 and Future Web Application

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

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

"utf-8";

Static Webpage Development

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

Web Design and Application Development

GIMP WEB 2.0 MENUS. Before we begin this tutorial let s visually compare a standard navigation bar and a web 2.0 navigation bar.

Cascading Style Sheets for layout II CS7026

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

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

Introduction to Computer Science Web Development

<page> 1 Document Summary Document Information <page> 2 Document Structure Text Formatting <page> 3 Links Images <page> 4

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

Web Development and Design Foundations with HTML5 8th Edition

NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS

Announcements. 1. Class webpage: Have you been reading the announcements? Lecture slides and coding examples will be posted

Module 2 (III): XHTML

Micronet International College

Introduction to WEB PROGRAMMING

Transcription:

1 HTML HTML is now very well standardized, but sites are still not getting it right HTML tags adaptation

HTML 2 HTML = HyperText Markup Language is used for the structural part of web pages Our strategy for backward compatibility plus future proofing is to use HTML5 For development, either we will use XHTML5 and send pages with content type application/xhtml+xml to get instant feedback and occasionally validate, or we will set up a validation scheme We may support old browsers

Old browsers 2a To support old browsers, if you are using XHTML5, you need to do two things One is to use the Polyglot HTML5 standard to write pages which work both as HTML5 and XHTML5 The other is to do content negotiation, i.e. check if the request Accepts header contains application/xhtml+xml or not and deliver pages with a response Content-Type header which is either application/xhtml+xml or text/html accordingly

Reference 3 The best general sources of information are: HTML5 standard, Polyglot HTML5 Mozilla Developer Network Web Platform HTML5 Rocks, Can I use, w3schools Random tutorial or Q&A sites generally contain obsolete, incorrect and incomplete info This chapter shows some available tags, leaving style, scripts, images, media etc. until later

The Template 4 To start a new web page, copy and paste this: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb" xml:lang="en-gb"> <head> <meta charset="utf-8"/> <title>put Title Here</title> </head> <body> <h1>put Heading Here</h1> </body> </html> html This must be exact, so never type it doctype lang charset title bom HTML4

The Doctype tag 4a The purpose of the DOCTYPE tag is to trigger standards mode in all browsers (not "quirks" or "limited quirks" or "almost standards" mode) and these are wrong: <?xml version="1.0"?> <!DOCTYPE html> <!-- comment --> <!DOCTYPE html> <!doctype html> bad html bad html bad html Getting this wrong is a disaster, because then even validators may fail to spot errors

Human language 4b The purpose of the lang attributes is to tell spell checkers, translation tools, and screen-readers for the blind, what human language the page is written in, so they are required The language code (en-gb for UK English) is repeated twice, so both HTML and XHTML browsers understand

Charset 4c A common mistake is to think that <meta charset="utf- 8"/> tells browsers that the page uses the UTF-8 charset Browsers use the response header (the only contenttype hint for files is the extension, which is insufficient) so the server has to be set up properly as well The meta tag is for humans and offline tools, especially validators, where there is no response header In HTML4, this can't be done without specifying the content type, which is wrong if content negotiation is used, so it is best to leave it out and rely on being able to configure offline tools

The title 4d The title doesn't appear in the page, it appears in the browser's title bar, or tab name, the user's history, and in bookmarks A title should make reasonable sense in these contexts, though it is often OK to repeat the main heading, which does appear on the page The standard insists that a title element should be present, and that its content should not just be white space

The BOM 4e The Byte Order Mark is an initial character used to distinguish the order of bytes in UTF-16 While allowed for historical reasons in UTF-8 (even in Polyglot HTML5), it is usually invisible, and it often causes trouble I strongly recommend making sure your editor doesn't use it

The HTML4 Template 4f The equivalent for HTML4/XHTML1.0 is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-gb" xml:lang="en-gb"> <head> <title>put Title Here</title> </head> <body> <h1>put Heading Here</h1> </body> </html> But don't use it in this course, unless you have permission for an exceptional reason

Layout 5 Many pages use fixed layout (usually fixed width) because the author wants total control. With fluid layout, you say what you want displayed, and the browser and visitor choose how. With responsive layout you use a framework so that the layout of the page adapts itself to different browsers, including mobiles. Using a fixed layout is (usually) wrong; it violates the principle of assuming nothing about visitors visitors Fluid layout is what you get if you keep everything really simple and don't try to do anything clever

Visitor assumptions 5a Web authors need to avoid being arrogant; a web page is a cooperation between an author and a visitor, and a visitor's preferences matter You shouldn't assume anything about desktop versus tablet versus mobile, or screen size, or resolution, or aspect ratio, or preferences For example, even if you assume a visitor is using a modern big-screen desktop, they may use half-width browser windows because they have many windows on screen at once (especially if they are computer scientists)

Block and inline tags 6 Tags are divided roughly into block tags (vertical) and inline tags (horizontal) The HTML5 document calls them (roughly) flow and phrasing tags, but the words block and inline are used in stylesheets and scripts Some tags are now allowed in either context, and have 'transparent' content, meaning what's allowed inside is the same as what's allowed outside

Block Tags 7 Some block tags are: <h1> <h2>... <h6> headings <p> paragraphs <br> line breaks (use sparingly) <ul> <ol> <li> <dl> <dt> <dd> lists <fieldset> box round form fields <pre> fixed width & format text <hr> horizontal rule (line)

The div tag 8 The div (division) element is a block-level wrapper which has no effect, except that it provides a place to add style or scripting For example, a group of paragraphs can be given a different background We will see that there are new HTML5 tags which say why you are adding a wrapper, so you will hardly ever need div, but knowing about it helps in understanding tutorial sites

Inline Tags 9 Some inline tags are: <em> <strong> <dfn> <code> <kbd> <samp> <var> <cite> <q> <sub> <sup> Some that you should use a lot less are <b> <i> <u> <ins> <del> <big> <small> <tt> The trouble is that they don't say what you mean, so it is generally better to use more meaningful tags, then use a stylesheet to say how you want them to look

The span tag 10 The span element is an inline-level wrapper which has no effect, except that it provides a place to add style or scripting It is the inline version of the div element For example, a sentence can be given a different background Again, there are more meaningful new tags in HTML5 which reduce the need for span tags

New Tags 11 In HTML5, there are new (div-like) sectioning tags, e.g.: <header> <footer> <nav> <main> <section> <article> <aside> <figure> There are new (span-like) phrasing tags, e.g.: <mark> <time> <command> There are new media tags, e.g.: <video> <audio> <canvas> <svg> <math> See the HTML5 differences from HTML4 document

Void elements 12 For compatibility, the polyglot standard insists that the self-closing tag syntax must be used for void (always empty) elements: area base br img input keygen link meta param source track wbr Explicit open and close tags must be used for all other empty elements: <img src="pic.png" /> <script src="do.js"></script> html

White Space Doesn't Matter 13 One consequence of fluid design is that in your source text, white space makes no difference: <p>this is a paragraph of text written on two lines in the source</p> html The source text above might end up in the browser looking like the text on the right or the text below This is a paragraph of text written on two lines in the source This is a paragraph of text written on two lines in the source

White Space Matters 14 In XHTML, there should be no newline at the start of pre or textarea and for tags with inline text content, you should not put a space after the start tag or before the end tag, because in some browsers it can look wrong or spoil copy-and-paste: <pre>no initial newline... <p>no space at either end</p> <td>same with a table cell</td> <a href="...">same with a link</a> Same with <i>italics</i> html

Tables 15 Simple tables look like this (see tbody note): <table><tbody> <tr> <td>top left</td> <td>top right</td> </tr> <tr> <td>bottom left</td> <td>bottom right</td> </tr> </tbody></table> html Tables used to be used a lot for magazine-style columns or other layout issues, but it is usually better to use stylesheets or other techniques now

Forms 16 Although we can't make forms do anything yet, the tags which are relevant to forms are: <form> <input> <textarea> <button> <select> <option> <fieldset> and a simple form is: <form action="params.html" method="get"> <input type="text" name="pet" value="cat" /> <input type="text" name="car" value="bmw" /> <input type="submit" value="go" /> </form> html The action is a URL saying what page to visit, the method is "post" ("get" for debugging), the form content is any HTML, plus inputs of various types

Links 17 For maximum clarity, indent links: <p class="indent"><a href="url">description</a></p>.indent { margin-left:40px; } css The url should be page-local (#explain) in the same page folder-local (x.html or dir/x.html) if close by site-local (/dir/x.html) if same site protocol-local (//www...) for http/https full (http://www...) otherwise Replace & by & (e.g. page?x=1&y=2)

Ids and classes 18 Any element can be given a unique id, so it can be picked up by code in a script (or targeted by a stylesheet) <button id="save">...</button> html Any element can be given a class, or a space-separated list of classes, so it can be targeted by a stylesheet (or picked up by a script) <code class="java">...</code> <code class="c">...</code> html

Entities 19 It is OK to use UTF-8 characters directly (if you set the server up suitably) or to use numeric entities (e.g. π or π) But in XHTML, the only accepted named entities are < > & &apos; and " This sometimes causes problems if you use libraries which insist on using entities like or There is a way of defining extra entities,

Extra entities 19a Here's how you can define extra entities (works with XHTML delivery only) <!DOCTYPE html [ <!ENTITY nbsp " " > <!ENTITY copy " " > ]> html This can be used with frameworks which insert entities for you and don't let you customize

Adaptation 20 When you have a valid page that works in your development browser, it should instantly work on other new browsers The next step is to make it work on old browsers It is no longer regarded as sensible to spend huge amounts of time and effort on this Instead, it is better to look for polyfills and frameworks that do the work for you

Tags as hooks 21 HTML tags describe the structure of a page; they are not supposed to control how a page looks or behaves In a way, they are all just hooks on which to hang style and scripting Therefore almost all the work to support old browsers is done in stylesheets and scripts, and not in the HTML

Example: a simple polyfill document.createelement('section'); section { display: block; } 22 js css The new section element works exactly the same as the old div element; it is just a block-level wrapper One line of JavaScript stops old browsers from ignoring it, and one line of CSS (or JavaScript) makes it look right If you feel you must support IE8, comments are useful conditional

Conditional Comments 22a Conditional comments are a non-standard feature of IE: <!--[if IE]>IE only<![endif]--> <!--[if!ie]><!-->non-ie<!--<![endif]--> Since the feature was removed in IE9, this neatly allows you, for example, to add an extra stylesheet or script just for IE8 (or IE9+ in 'compatibility mode') Beware You must use copy-and-paste, and avoid other wrong sources of info: see next slide

Details 22b It is incredibly easy to get the details wrong. Even a single character out of place spoils everything. Most tutorials give versions which don't work in XHTML. Conditional comments only work in HTML, not in style sheets. It is possible to target specific versions of IE, but since IE8 is the only extant version which recognises the notation, there is no point JavaScript shouldn't be used to detect browsers by name, because (a) browsers lie, and (b) you don't know what future browsers will be called

Choices 23 Your pages must be valid, otherwise they won't look the same on all browsers, but you have three choices of standard to follow: HTML5 XHTML5 Polyglot HTML5 = HTML5 + XHTML5

The HTML5 Choice 24 For this, take out the xmnls attribute from the <html> tag, and configure the server to deliver all pages as text/html instead of using content negotiation Advantages: better for some frameworks, a bit less fussy Disadvantages: you don't get any feedback from the browser for invalid pages, so you must use vnu.jar for validation (and you need to understand the 'unfussy' rules)

The XHTML5 Choice 25 For this, include the xmnls attribute in the <html> tag, configure the server to deliver all pages as application/xhtml+xml, and follow the tighter rules (e.g. no missing close tags) Advantages: you get instant feedback from the browser for pages which are not well formed Disadvantages: you cannot support old browsers, and your framework may not support it

The Polyglot Choice 26 For this, include the xmnls attribute in <html>, configure the server to use content negotiation to send pages as text/html or application/xhtml+xml according to the browser, and follow even tighter rules (e.g. <img.../> and <script..></script>) Advantages: you get instant feedback from the browser for pages which are not well formed, and you support old browsers Disadvantages: the rules are a bit fussy, you may need vnu.jar occasionally, and your framework may not support it