<<

Lesson: Web Programming(2) Omid Jafarinezhad

Sharif University of Technology ● HTTP, JavaScript, CSS, HTML5, ReactJs, Flow, Progressive Web App

● Golang, NodeJs, MongoDB, PostgreSQL, Redis

● Docker, Git, YUIDoc, Jest, Materials WebPack, Gulp, Browserify, Locust

● (Optional/Research) Kubernetes, InfluxDB, RabbitMQ, gRPC, Ansible XML eXtensible Markup Language

It was designed to store and transport data

It was designed to be both human- and machine-readable

XML Does Not Use Predefined Tags

● HTML works with predefined tags like

,

, , etc

XML syntax

XML Documents Must Have a Root Element

The XML

All XML Elements Must Have a Closing Tag

XML Tags are Case Sensitive XML syntax (2)

XML Elements Must be Properly Nested

XML elements can have attributes in name/value pairs

Some characters have a special meaning X XML syntax (3)

Special character

Comments XML Namespaces

Element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications

A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource

The namespace declaration has the following syntax. xmlns:prefix="URI"

Document Object Model (DOM)

DOM is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document

-- ch02-01.

XSLT, XPath, XQuery

XSLT (eXtensible Stylesheet Language Transformations) standard

● It can transform an XML document into HTML ● It is a styling language for XML ● XQuery is the language for querying XML data ● XQuery is to XML what SQL is to ● XPath is a major element in the XSLT ● XPath can be used to navigate through elements and attributes in an XML document ○ XPath uses path expressions to navigate in XML documents XSLT example

--ch02-02-.

--ch02-02.xml XPath example

//*[@id="tsf"]/div[2]/div[3]/center/input[1]

[@id="tsf"]

div[2]

div[3] center input[1] XML DTD

An XML document with correct syntax is called "Well Formed"

An XML document validated against a DTD is both "Well Formed" and "Valid"

The purpose of a DTD is to define the structure of an XML document

JavaScript Object Notation (Json)

JSON is a lightweight text-based open standard designed for human-readable data interchange

Web services and use JSON format to provide public data

JSON is language independent and filename extension is .

Data is represented in name/value pairs

● Curly braces hold objects and each name is followed by ':'(colon), the name/value pairs are separated by , (comma) ● Square brackets hold arrays and values are separated by ,(comma) JSON DataTypes

Number, String, Boolean, Array, an object (JSON object), null HTML History

1989 Tim Berners-Lee invented www 1991 Tim Berners-Lee invented HTML 1993 Dave Raggett drafted HTML+ 1995 HTML Working Group defined HTML 2.0 1997 W3C Recommendation: HTML 3.2 1999 W3C Recommendation: HTML 4.01 2000 W3C Recommendation: XHTML 1.0 2008 WHATWG HTML5 First Public Draft 2012 WHATWG HTML5 Living Standard 2014 W3C Recommendation: HTML5 2016 W3C Candidate Recommendation: HTML 5.1 Hyper Text Markup Language (HTML)

HTML elements are the building blocks of HTML pages

Browsers do not display the HTML tags, but use them to render the content of the page

HTML tags are not case sensitive:

means the same as

● but W3C recommends lowercase in HTM --ch02-04.html HTML Headings

--ch02-05.html HTML Paragraphs

--ch02-06.html Do Not Forget the End Tag

Some HTML elements will display correctly, even if you forget the end tag Line break


is an empty element

--ch02-07.html HTML Attributes

Attributes provide additional information about HTML elements

Double quotes around attribute values are the most common in HTML, but single quotes can also be used HTML Attributes (2)

By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference ".

[ref] https://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 HTML Horizontal Rules

--ch02-08.html HTML

 Element text inside a 
 element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks

--ch02-09.html The HTML Style Attribute

--ch02-10.html HTML Fonts

--ch02-11.html HTML Text Size

--ch02-12.html HTML Text Alignment

--ch02-13.html HTML Text Formatting Elements

Defines bold text; There is no semantic meaning Defines emphasized text, with added semantic importance Defines italic text; There is no semantic meaning Defines smaller text Defines important text, with added semantic importance Defines subscripted text Defines superscripted text Defines inserted text Defines deleted text Defines marked/highlighted text --ch02-14.html HTML Quotation and Citation Elements

Defines an abbreviation or acronym

Defines contact information. displayed in italic. Most browsers will add a line break before and after the element Defines the text direction
Defines a section that is quoted from another source, usually indent the element Defines the title of a work, usually display in italic Defines a short inline quotation

--ch02-15.html HTML Comment Tags

Conditional Comments HTML Images

Images (including GIF) are defined with the tag

The alt attribute provides an alternate text for an image, if the user for some reason cannot view it (because of slow connection, an error in the src attribute, etc.) width and height attributes, values are specified in pixels by default --ch02-16.html image-map is an image with clickable areas

The Element

HTML5 introduced the element to add more flexibility when specifying image resources

The element contains a number of elements, each referring to different image sources. This way the browser can choose the image that best fit the current view and/or device ● Each element have attributes describing when their image is the most suitable

Always specify an element as the last child element of the element. The element is used by browsers that do not support the element, or if none of the tags matched Resize browser HTML Links - Hyperlinks

Links can be absolute URL (A full web address) or relative URL (link to the same web site)

The target Attribute

● _blank: Opens the linked document in a new window or tab ● _self: Opens the linked document in the same window/tab as it was clicked (this is default) ● _parent: Opens the linked document in the parent frame (immediate) ● _top: Opens the linked document in the full body of the window ● framename: Opens the linked document in a named frame --ch02-17.html Unordered HTML List

--ch02-18.html Choose List Item Marker disc bullet list item marker (default) circle circle list item marker square square list item marker none The list items will not be marked Ordered HTML List

--ch02-19.html Ordered HTML List - The Type Attribute type="1" The list items will be numbered with numbers (default) type="A" The list items will be numbered with uppercase letters type="a" The list items will be numbered with lowercase letters type="I" The list items will be numbered with uppercase roman numbers type="i" The list items will be numbered with lowercase roman numbers HTML Description Lists

--ch02-20.html Nested HTML Lists Horizontal Lists HTML Block Elements

A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can)

Examples of block-level elements:

tag

Each table row is defined with the

tag

A table header is defined with the

tag

● By default, table headings are bold and centered

A table data/cell is defined with the

tag

The

tag defines a table caption

● The

tag must be inserted immediately after the tag --ch02-23.html --ch02-24.html --ch02-25.html --ch02-26.html --ch02-27.html --ch02-28.html HTML head Elements

The element is a container for metadata (data about data) and is placed between the tag and the tag

Metadata is not displayed

Metadata typically define the document title, character set, styles, links, scripts, and other meta information

, <style>, <meta>, <link>, <script>, and <base> The HTML <title> Element defines a title in the browser tab provides a title for the page when it is added to favorites displays a title for the page in search engine results The HTML <style> And <link> Element For HTML4:</p><p>For HTML5: The HTML <meta> Element</p><p>The <meta> element is used to specify which character set is used, page description, keywords, author, and other metadata</p><p>Metadata is used by browsers (how to display content), by search engines (keywords), and other web services</p><p><!-- Refresh document every 30 seconds --> Setting The Viewport</p><p>HTML5 introduced a method to let web designers take control over the viewport</p><p>The HTML <script> Element The HTML <base> Element</p><p>The <base> element specifies the base URL and base target for all relative URLs in a page Omitting <html>, <head> and <body>?</p><p>According to the HTML5 standard; the <html>, the <body>, and the <head> tag can be omitted does not recommend omitting the <html> and <body> tags</p><p>● errors in older browsers (IE9) Useful HTML Character Entities</p><p>< less than < < > greater than > > & ampersand & & " double quotation mark " " ' single quotation mark (apostrophe) ' ' ¢ cent ¢ ¢ £ pound £ £ ¥ yen ¥ ¥ € euro € € © copyright © © ® registered trademark ® ® The <form> Element used to collect user input</p><p>The action attribute defines the action to be performed when the form is submitted The <input> Element</p><p>The <input> element is the most important form element</p><p>The <input> element can be displayed in several ways, depending on the type attribute</p><p>● <input type="text"> a one-line text input field ● <input type="radio"> a radio button ● <input type="submit"> a submit button (for submitting the form) ● <input type="password"> defines a password field ● ... Text Input Radio Button Input The Submit Button Input Type Password Input Type Reset defines a reset button that will reset all form values to their default values Input Type Checkbox HTML5 Input Types</p><p>● Color ● Range ● Date ● search ● Datetime-local ● Tel ● Email ● Time ● month ● Url ● number ● week Input Type Color</p><p>Does not supported in Internet Explorer 11 and earlier versions or Safari 9.1 and earlier versions Input Type Date</p><p>Does not supported in <a href="/tags/Firefox/" rel="tag">Firefox</a>, or Internet Explorer 11 and earlier versions Input Type Range</p><p>Does not supported in Internet Explorer 9 and earlier versions Input Type Email</p><p>Depending on browser support, the e-mail address can be automatically validated when submitted</p><p>Does not supported in IE9 and earlier</p><p>Input Restrictions</p><p>Here is a list of some common input restrictions (some are new in HTML5) Example The Method Attribute</p><p>The method attribute specifies the HTTP method (GET or POST) to be used when submitting the form data does not supported in Internet Explorer 9 and earlier versions, or in Safari The list Attribute</p><p>HTML5</p><p>The datalist tag is not supported in Internet Explorer 9 and earlier versions, or in Safari When to Use GET?</p><p>The default method when submitting form data is GET</p><p> submitted form data will be visible in the page address field</p><p>GET must NOT be used when sending sensitive information! </p><p>GET is best suited for short, non-sensitive, amounts of data, because it has size limitations too When to Use POST?</p><p>Always use POST if the form data contains sensitive or personal information</p><p>● The POST method does not display the submitted form data in the page address field</p><p>POST has no size limitations, and can be used to send large amounts of data The Name Attribute</p><p>Each input field must have a name attribute to be submitted</p><p>● If the name attribute is omitted, the data of that input field will not be sent at all</p><p>This example will only submit the "Last name" input field Grouping Form Data with <fieldset> The <select> Element (drop-down list)</p><p>The <option> elements defines an option that can be selected</p><p>● To define a pre-selected option, add the selected attribute to the option The <textarea> Element</p><p>The rows attribute specifies the visible number of lines in a text area The cols attribute specifies the visible width of a text area</p><p>The <button> Element HTML Layouts</p><p>HTML5 offers new semantic elements that define the different parts of a web page</p><p>● <header> - Defines a header for a document or a section ● <nav> - Defines a container for navigation links ● <section> - Defines a section in a document ● <article> - Defines an independent self-contained article ● <aside> - Defines content aside from the content (like a sidebar) ● <footer> - Defines a footer for a document or a section ● <details> - Defines additional details ● <summary> - Defines a heading for the <details> element section element</p><p>The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content</p><p>The theme of each section should be identified, typically by including a heading (h1-h6 element) as a child of the section element</p><p>A Web site's home page could be split into sections for an introduction, news items, and contact information Note</p><p>[https://www.w3.org/TR/html5/sections.html#the-article-element] … Authors are encouraged to use the article element instead of the section element when it would make sense to syndicate the contents of the element</p><p>… The section element is not a generic container element. When an element is needed only for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. 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 Note(2)</p><p>...Not all groups of links on a page need to be in a nav element — the element is primarily intended for sections that consist of major navigation blocks. In particular, it is common for footers to have a short list of links to various pages of a site, such as the terms of service, the home page, and a copyright page. The footer element alone is sufficient for such cases; while a nav element can be used in such cases, it is usually unnecessary</p><p>HTML Media</p><p>Multimedia comes in many different formats. It can be almost anything you can hear or see</p><p>MPEG Developed by the Moving Pictures Expert Group. The first ● .mpg popular video format on the web. Used to be supported by all ● .mpeg browsers, but it is not supported in HTML5 (See MP4)</p><p>AVI and WMV AVI (Audio Video Interleave) and WMV (Windows Media Video) ● .wmv Developed by Microsoft. Commonly used in video cameras ● .avi and TV hardware. Plays well on Windows computers, but not in web browsers HTML Media</p><p>Flash Developed by Macromedia. Often requires an extra ● .swf/.flv component (plug-in) to play in web browsers</p><p>QuickTime Developed by Apple. Commonly used in video cameras and ● .mov TV hardware. Plays well on Apple computers, but not in web browsers. (See MP4)</p><p>RealVideo Developed by Real Media to allow video streaming with low ● .rm/ram bandwidths. It is still used for online video and Internet TV, but does not play in web browsers HTML Media</p><p>Ogg Developed by the Xiph.Org Foundation. Supported by ● .ogg HTML5</p><p>WebM Developed by the web giants, Mozilla, Opera, Adobe, and ● .webm Google. Supported by HTML5</p><p>MPEG-4/MP4 Developed by the Moving Pictures Expert Group. Based on ● .mp4 QuickTime. Commonly used in newer video cameras and TV hardware. Supported by all HTML5 browsers HTML5 Audio</p><p>The <source> element allows you to specify alternative audio files which the browser may choose from. The browser will use the first recognized format HTML5 Video</p> </div> </div> </div> </div> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js" integrity="sha512-aVKKRRi/Q/YV+4mjoKBsE4x3H+BkegoM/em46NNlCqNTmUYADjBbeNefNxYV7giUp0VxICtqdrbqU7iVaeZNXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="/js/details118.16.js"></script> <script> var sc_project = 11552861; var sc_invisible = 1; var sc_security = "b956b151"; </script> <script src="https://www.statcounter.com/counter/counter.js" async></script> <noscript><div class="statcounter"><a title="Web Analytics" href="http://statcounter.com/" target="_blank"><img class="statcounter" src="//c.statcounter.com/11552861/0/b956b151/1/" alt="Web Analytics"></a></div></noscript> </body> </html>