cse3026: web application development basic...

53
CSE3026: Web Application Development Basic HTML Scott Uk-Jin Lee Reproduced with permission of the authors. Copyright 2012 Marty Stepp, Jessica Miller, and Victoria Kirst. All rights reserved. Further reproduction or distribution is prohibited without written permission.

Upload: others

Post on 20-Feb-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

  • CSE3026: Web Application Development Basic HTML

    Scott Uk-Jin LeeReproduced with permission of the authors. Copyright 2012 Marty Stepp, Jessica Miller, and Victoria Kirst.

    All rights reserved. Further reproduction or distribution is prohibited without written permission.

    http://validator.w3.org/check/refererhttp://jigsaw.w3.org/css-validator/check/referer

  • 2.1: Basic HTML

    2.1: Basic HTML2.2: More HTML Elements2.3: Web Standards

  • Hypertext Markup Language (HTML)

    describes the content and structure of information on a web pagenot the same as the presentation (appearance on screen)

    surrounds text content with opening and closing tagseach tag's name is called an element

    syntax: content example:

    This is a paragraph

    most whitespace is insignificant in HTMLignored or collapsed to a single space

    we will use a newer version called HTML5

    http://www.w3schools.com/html/default.asp

  • Structure of an HTML page

    information about the page

    page contents

    the header describes the page and the body contains the page's contentsan HTML page is saved into a file ending with extension .htmlDOCTYPE tag tells browser to interpret our page's code as HTML5, the latest/greatest version of thelanguage

  • Page title:

    describes the title of the web page

    Chapter 2: HTML Basics

    placed within the head of the pagedisplayed in the web browser's title bar and when bookmarking the page

    http://www.w3schools.com/tags/tag_title.asp

  • Paragraph:

    paragraphs of text (block)

    You're not your job. You're not how much money you have in the bank. You're not the car you drive. You're not the contents of your wallet. You're not your khakis. You're the all-singing, all-dancing crap of the world.

    You're not your job. You're not how much money you have in the bank. You're not the car you drive. You're not the contents of your wallet. You'renot your khakis. You're the all-singing, all-dancing crap of the world.

    placed within the body of the pagemore paragraph examples

    http://www.w3schools.com/tags/tag_p.asphttp://www.w3schools.com/tags/tryit.asp?filename=tryhtml_paragraphs2

  • Headings: , , ...,

    headings to separate major areas of the page (block)

    University of Whoville Department of Computer Science Sponsored by Micro$oft

    University of Whoville

    Department of Computer Science

    Sponsored by Micro$oft

    More heading examples

    http://www.w3schools.com/tags/tag_hn.asphttp://www.w3schools.com/tags/tryit.asp?filename=tryhtml_headers

  • Horizontal rule:

    a horizontal line to visually separate sections of a page (block)

    First paragraph

    Second paragraph

    First paragraph

    Second paragraph

    should be immediately closed with />

    http://www.w3schools.com/tags/tag_hr.asp

  • More about HTML tags

    some tags can contain additional information called attributessyntax: content example: Next page

    some tags don't contain content; can be opened and closed in one tagsyntax: example: example:

  • Links:

    links, or "anchors", to other pages (inline)

    Search Google or our Lecture Notes.

    Search Google or our Lecture Notes.

    uses the href attribute to specify the destination URLcan be absolute (to another web site) or relative (to another page on this site)

    anchors are inline elements; must be placed in a block element such as p or h1

    http://www.w3schools.com/tags/tag_a.asphttp://www.google.com/http://localhost/lectureSlides/lectures.html

  • Block and inline elements

    block elements contain an entire large region of contentexamples: paragraphs, lists, table cellsthe browser places a margin of whitespace between block elements for separation

    inline elements affect a small amount of contentexamples: bold text, code fragments, imagesthe browser allows many inline elements to appear on the same linemust be nested inside a block element

    http://htmlhelp.com/reference/html40/block.htmlhttp://www.cs.sfu.ca/CC/165/sbrown1/wdgxhtml10/inline.html

  • Images:

    inserts a graphical image into the page (inline)

    the src attribute specifies the image URLHTML5 also requires an alt attribute describing the image

    http://www.w3schools.com/tags/tag_img.asp

  • More about images

    if placed in an a anchor, the image becomes a linktitle attribute is an optional tooltip (on ANY element)

    http://theonering.net/

  • Line break:

    forces a line break in the middle of a block element (inline)

    Teddy said it was a hat,
    So I put it on.

    Now Daddy's sayin',
    Where the heck's the toilet plunger gone?

    Teddy said it was a hat, So I put it on.

    Now Daddy's sayin', Where the heck's the toilet plunger gone?

    Warning: Don't over-use br (guideline: >= 2 in a row is bad)

    br should not be used to separate paragraphs or used multiple times in a row to create spacing

    http://www.w3schools.com/tags/tag_br.asp

  • Phrase elements: ,

    em: emphasized text (usually rendered in italic) strong: strongly emphasized text (usually rendered in bold)

    HTML is really, REALLY fun!

    HTML is really, REALLY fun!

    as usual, the tags must be properly nested for a valid page

    http://www.w3schools.com/tags/tag_em.asphttp://www.w3schools.com/tags/tag_strong.asp

  • Nesting tags

    HTML is really, REALLY lots of fun!

    tags must be correctly nested(a closing tag must match the most recently opened tag)

    the browser may render it correctly anyway, but it is invalid HTML(how would we get the above effect in a valid way?)

  • Comments:

    comments to document your HTML file or "comment out" text

    CSE courses are a lot of fun!

    CSE courses are a lot of fun!

    many web pages are not thoroughly commented (or at all)still useful at top of page and for disabling codecomments cannot be nested and cannot contain a --

    http://www.w3schools.com/tags/tag_comment.asp

  • 2.2: More HTML Elements

    2.1: Basic HTML2.2: More HTML Elements2.3: Web Standards

  • Unordered list: ,

    ul represents a bulleted list of items (block) li represents a single item within the list (block)

    No shoes No shirt No problem!

    No shoesNo shirtNo problem!

    http://www.w3schools.com/tags/tag_ul.asphttp://www.w3schools.com/tags/tag_li.asp

  • More about unordered lists

    a list can contain other lists:

    Simpsons: Homer Marge Family Guy: Peter Lois

    Simpsons:HomerMarge

    Family Guy:PeterLois

  • Ordered list:

    ol represents a numbered list of items (block)

    RIAA business model:

    Sue customers ??? Profit!

    RIAA business model:

    1. Sue customers2. ???3. Profit!

    we can make lists with letters or Roman numerals using CSS (later)

    http://www.w3schools.com/tags/tag_ol.asp

  • Definition list: , ,

    dl represents a list of definitions of terms (block) dt represents each term, and dd its definition

    newbie one who does not have mad skills own to soundly defeat (e.g. I owned that newbie!) frag a kill in a shooting game

    newbieone who does not have mad skills

    ownto soundly defeat (e.g. I owned that newbie!)

    fraga kill in a shooting game

    http://www.w3schools.com/tags/tag_dl.asphttp://www.w3schools.com/tags/tag_dt.asphttp://www.w3schools.com/tags/tag_dd.asp

  • Quotations:

    a lengthy quotation (block)

    As Lincoln said in his famous Gettysburg Address:

    Fourscore and seven years ago, our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.

    As Lincoln said in his famous Gettysburg Address:

    Fourscore and seven years ago, our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to theproposition that all men are created equal.

    http://www.w3schools.com/tags/tag_blockquote.asp

  • Inline quotations:

    a short quotation (inline)

    Quoth the Raven, Nevermore.

    Quoth the Raven, "Nevermore."

    Why not just write the following?

    Quoth the Raven, "Nevermore."

    We don't use " marks for two reasons:

    1. HTML shouldn't contain literal quotation mark characters; they should be written as "2. using allows us to apply CSS styles to quotations (seen later)

    http://www.w3schools.com/tags/tag_q.asp

  • HTML Character Entities

    a way of representing any Unicode character within a web page

    character(s) entity

    < > < >

    é è ñ é è ñ

    ™ © ™ ©

    π δ Δ π δ ΔИ И" & " &

    More HTML entitiesHow would you display the text & on a web page?

    http://en.wikipedia.org/wiki/Unicodehttp://www.w3schools.com/html/html_entities.asp

  • HTML-encoding text

    Search Google for Marty

    Search Google for Marty

    To display the link text in a web page, its special characters must be encoded as shown above

  • Deletions and insertions: ,

    content that should be considered deleted or added to the document (inline)

    Final Exam Midterm is on Dec 10-15 Oct 10-11.

    Final Exam Midterm is on Dec 10-15 Oct 10-11.

    http://www.w3schools.com/tags/tag_del.asphttp://www.w3schools.com/tags/tag_ins.asp

  • Abbreviations:

    an abbreviation, acronym, or slang term (inline)

    Safe divers always remember to check their SCUBA gear.

    Safe divers always remember to check their SCUBA gear.

    http://www.w3schools.com/tags/tag_abbr.asp

  • Computer code:

    a short section of computer code (usually shown in a fixed-width font)

    The ul and ol tags make lists.

    The ul and ol tags make lists.

    http://www.w3schools.com/tags/tag_code.asp

  • Preformatted text:

    a large section of pre-formatted text (block)

    Steve Jobs speaks loudly reality distortion Apple fans bow down

    Steve Jobs speaks loudly reality distortion Apple fans bow down

    displayed with exactly the whitespace / line breaks given in the textshown in a fixed-width font by defaulthow would it look if we had instead enclosed it in code tags?

    http://www.w3schools.com/tags/tag_pre.asp

  • Web page metadata:

    information about your page (for a browser, search engine, etc.)

    placed in the head section of your HTML pagemeta tags often have both the name and content attributes

    some meta tags use the http-equiv attribute instead of name

    http://www.w3schools.com/tags/tag_meta.asp

  • Favorites icon ("favicon")

    the link tag, placed in the head section, attaches another file to the pagein this case, an icon to be placed in the browser title bar and bookmarks

  • HTML tables: , ,

    A 2D table of rows and columns of data (block element)

    1,11,2 okay 2,1 real wide2,2

    1,1 1,2 okay2,1 real wide 2,2

    table defines the overall table, tr each row, and td each cell's datatables are useful for displaying large row/column data setsNOTE: tables are sometimes used by novices for web page layout, but this is not proper semanticHTML and should be avoided

    http://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_td.asp

  • Table headers, captions: ,

    My important data Column 1Column 2 1,11,2 okay 2,1 real wide2,2

    My important dataColumn 1 Column 2

    1,1 1,2 okay2,1 real wide 2,2

    th cells in a row are considered headers; by default, they appear bolda caption at the start of the table labels its meaning

    http://www.w3schools.com/tags/tag_th.asphttp://www.w3schools.com/tags/tag_caption.asp

  • 2.3: Web Standards

    2.1: Basic HTML2.2: More HTML Elements2.3: Web Standards

  • Web Standards

    It is important to write proper HTML code and follow proper syntax.Why use valid HTML and web standards?

    more rigid and structured languagemore interoperable across different web browsersmore likely that our pages will display correctly in the futurecan be interchanged with other XML data: SVG (graphics), MathML, MusicML, etc.

    http://en.wikipedia.org/wiki/Scalable_Vector_Graphicshttp://en.wikipedia.org/wiki/MathMLhttp://en.wikipedia.org/wiki/MusicXMLhttp://en.wikipedia.org/wiki/List_of_XML_markup_languages

  • W3C HTML Validator

    validator.w3.orgchecks your HTML code to make sure it follows the official HTML syntaxmore picky than the browser, which may render bad HTML correctly

    http://validator.w3.org/check/refererhttp://validator.w3.org/

  • What is HTML 5?

    a new W3C standard version of the HTML markup language successor to HTML 4.01 and XHTML 1.1balance between too-loose-ness of HTML 4 and too-strict-ness of XHTMLreduces the browser's need for plugins to display content, e.g. multimediamake web content more rich, semantically meaningful, descriptive, accessiblemore easily enable the web as an application platform (Web 2.0)

  • What's new in HTML 5?

    semantic tags: nav, aside, header, footer, section, aside, articleForms 2.0: sliders, search bars, color/number/email/url/date/time,placeholders, ...

    audio and video tags for embedding multimedia

    canvas tag for drawing 2D shapes in HTML/JS (like DrawingPanel) (ref 1, 2, 3)

    http://slides.html5rocks.com/http://www.w3schools.com/html5/html5_reference.asphttp://thinkvitamin.com/dev/html-5-dev/how-to-draw-with-html-5-canvas/http://blog.nihilogic.dk/2009/02/html5-canvas-cheat-sheet.htmlhttps://developer.mozilla.org/en/canvas_tutorial

  • What's new, continued

    semantic web / microdata attributes: rel="...", itemscope, itemtype, itemprop

    accessibility features ("ARIA")embedding of rich XML-like formats such as SVG vector graphicsother stuff: offline apps, geolocation, cross-document messaging, MIME typeregistration, history management, ...

    http://en.wikipedia.org/wiki/Semantic_Webhttp://standardssuck.org/aria-in-html5http://en.wikipedia.org/wiki/Svg

  • Multimedia is fun

  • File formats

    some differ in features (animation, 5.1 stereo, transparency)many multimedia formats use compression to reduce file size

    compression algorithms are also called codecs (list)some compression algorithms are "lossless", others are "lossy"

    some formats are patented (unusable in free software)some formats are encrypted to protect information inside

    Digital Rights Management (DRM) restricts what user can do with filecan be broken: DVD (DeCSS), HD DVD (09f911029d74e35bd84156c5635688c0)

    some formats are streaming (can play while downloading)

    comparisons of formats: audio/video containers

    http://en.wikipedia.org/wiki/Data_compressionhttp://en.wikipedia.org/wiki/Codechttp://en.wikipedia.org/wiki/List_of_codecshttp://en.wikipedia.org/wiki/Encryptionhttp://en.wikipedia.org/wiki/Digital_rights_managementhttp://en.wikipedia.org/wiki/DeCSShttp://en.wikipedia.org/wiki/Streaming_mediahttp://en.wikipedia.org/wiki/Comparison_of_container_formats

  • Image file formats

    JPEG : uses "lossy compression"; small file size; good for photosGIF : 256 colors; LZW run-length encoding lossless compression

    allows transparency (can see behind parts of image)possible to create animated GIFs

    PNG : free format created to avoid patent and color issues in GIF format; lossless compression,transparencyothers: TIFF, BMPimage format comparisons: text, photo, PNG

    http://en.wikipedia.org/wiki/Jpeghttp://en.wikipedia.org/wiki/Lossy_compressionhttp://en.wikipedia.org/wiki/Gifhttp://en.wikipedia.org/wiki/Run_length_encodinghttp://en.wikipedia.org/wiki/Pnghttp://en.wikipedia.org/wiki/Tiffhttp://en.wikipedia.org/wiki/Bitmaphttp://paleo.org/BKsamples/http://philip.greenspun.com/wtr/img-format/http://en.wikipedia.org/wiki/Png

  • Raster and vector graphics

    the image formats on the previous slide are raster or bitmap formatsthey describe the pixels that should be drawn on the screen

    vector graphics formats such as SVG describe shapes/lines rather than pixelsadvantage: infinite precision; good for zooming, printingdisadvantage: not supported on all platforms; computationally expensive

    http://en.wikipedia.org/wiki/Vector_graphicshttp://en.wikipedia.org/wiki/SVG

  • Audio file formats

    MP3 : uses lossy compression that eliminates inaudible soundsAAC : Apple's iTunes audio file formatWMA / ASF: Microsoft Windows Media Audio formatOGG : Linux hippie audio/video formatRA / RM / RAM : Real Audio formatother formats: WAV (MS), AU (Sun), AIFF / SND (Apple), FLACSequenced Music: MID, MOD

    comparison of formats

    http://en.wikipedia.org/wiki/Mp3http://en.wikipedia.org/wiki/Advanced_Audio_Codinghttp://en.wikipedia.org/wiki/Windows_Media_Audiohttp://en.wikipedia.org/wiki/Ogghttp://en.wikipedia.org/wiki/RealAudiohttp://en.wikipedia.org/wiki/Wavhttp://en.wikipedia.org/wiki/Au_file_formathttp://en.wikipedia.org/wiki/Aiffhttp://en.wikipedia.org/wiki/Flachttp://en.wikipedia.org/wiki/Musical_Instrument_Digital_Interface#MIDI_file_formatshttp://en.wikipedia.org/wiki/MOD_%28file_format%29http://en.wikipedia.org/wiki/Comparison_of_audio_codecs

  • Video file formats

    MPEG : Motion Picture standard video formatDVDs are encoded using MPEG-2HD DVDs are often compressed with MPEG-4 (H.264) codec

    MOV : Apple's QuickTime movie formatWMV / ASF : Microsoft's Windows Media Video formatAVI : classic Microsoft video format that can be encoded in many waysSWF / FLC : Macromedia Flash multimedia formatRV : Real Video format

    comparisons of formats: 1, 2

    http://en.wikipedia.org/wiki/Mpeghttp://en.wikipedia.org/wiki/Dvdhttp://en.wikipedia.org/wiki/HD_DVDhttp://en.wikipedia.org/wiki/H.264http://en.wikipedia.org/wiki/.movhttp://en.wikipedia.org/wiki/Wmvhttp://en.wikipedia.org/wiki/AVIhttp://en.wikipedia.org/wiki/Swfhttp://en.wikipedia.org/wiki/Real_Videohttp://www.uwm.edu/~price/video_file_format_comparison.htmlhttp://en.wikipedia.org/wiki/Comparison_of_video_codecs

  • Flash

    format for graphics, video, audio developed by Macromedia/Adobewidely used for many reasons:

    supported in most major platforms/browserslightweightcan produce impressive interactive animated content

    downside: proprietary; editing software costs money (viewer is free)examples: Duck Hunt, Homestar Runner

    http://en.wikipedia.org/wiki/Macromedia_flashhttp://localhost/lectureSlides/examples/multimedia/duckhunt.swfhttp://www.homestarrunner.com/

  • Linking to multimedia files

    My video

    browser has a list of default applications to associate with each file typeif it has an associated app, it will run itsome file types are displayed within the browser using pluginsif it doesn't know what to do, it will just download the filetry it yourself: MPG, MOV, WMV, RM, SWF, WAV, MID

    http://localhost/lectureSlides/examples/multimedia/developers.mpghttp://localhost/lectureSlides/examples/multimedia/win98.movhttp://localhost/lectureSlides/examples/multimedia/powerglove.wmvhttp://localhost/lectureSlides/examples/multimedia/flintstones.rmhttp://localhost/lectureSlides/examples/multimedia/duckhunt.swfhttp://localhost/lectureSlides/examples/multimedia/winxp.wavhttp://localhost/lectureSlides/examples/multimedia/town.mid

  • File types and browser plugins

    plugin: helper app launched within the browser to view certain file typesexamples: Flash player, QuickTime, Windows Media Player, Acrobat Reader, Java

    about:plugins URL will show you list of plugins in Firefoxenter preferences, then choose Content, File Types, Manage...

    can change which app/plugin will be used to open particular file types

    about:plugins

  • HTML 5 embedding a video

    yes, pleaseit'll also be easy to manipulate (play/pause/stop/etc.) the video via the JS DOMone drawback: drama over codecs such as MPEG 4 / H.264, Ogg Theora / VP3, WebM, AVI

    http://diveintohtml5.org/video.html

  • Embedded objects:

    this is how you used to embed a video prior to HTML5attributes: archive, classid, codebase, codetype, data, declare, height, name,standby, type, usemap, widthtype attribute specifies file's MIME typeIE6 requires non-standard classid attribute to specify which plugin to use (list)

    http://www.w3schools.com/tags/tag_object.asphttp://www.webmaster-toolkit.com/mime-types.shtmlhttp://en.wikipedia.org/wiki/Clsidhttp://www.castlecops.com/CLSID.html

  • Parameters:

    indicates a parameter to be passed to the embedded objectrequired name and value attributes tell the object what parameter this is and what value it should have

    http://www.w3schools.com/tags/tag_param.asp

  • Embedding a YouTube video

    parameters

    this code, unlike the code on YouTube's pages, is HTML5-compliant