Transcript Chapter 1

Module 7: HTML

1. What is HTML?

2. Basic syntax, document structure 3. Basic formatting, images, links 4. Lists, table, and forms Read these slides together with the example file 1 CP102 Module 7: HTML

What is HTML

What is HTML?

 HyperText Markup Language (HTML) is an Markup Language for marking up WWW documents  Markup: tags are used to indicate the formatting, layout and some features of documents. Markup does not show up in the display HTML allows user to    Publish documents to the Internet in a format not dependent on platform Present text, graphics and multimedia data Create links pointing to other WWW documents

CP102 Module 7: HTML

2

The development of HTML

HTML was originally developed by Tim Berners-Lee 1990, and had gone through a sequence of versions.    HTML2.0, 1995 => HTML3.2, 1997 HTML 4.0, 1997=>HTML 4.01, in 1999 HTML4.01

XHTML1.0, 2000 => XML (eXtensible Markup Language) XML is a more extended than HTML. It enables designers to create their own tags, structures to indicate specific information. XHTML is a special case of XML The development is guided by the World Wide Web Consortium (W3C)

CP102 Module 7: HTML

3

Standard HTML document structure

…… ..………………….

 The whole document must have as its root  A document consists of a head and a body  The tag is used to give the document a title, which is normally displayed in the browser’s window title bar</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>4</b></p> <a id="p5" href="#"></a> <h2>Basic Syntax</h2> <p>Tag and elements  Tags are markups to tell browser how to display it’s contents. An element: tags and its marked contents  Tag format:  Opening tag <name [ /] [atrribute=“value”]>   Closing tag </name> Not case sensitive The content of a tag appears between its opening tag and its closing tag. Not all tags have content  If a tag has no content, its form is <name />   Every tag that has content must have a closing tag Tags must be properly nested Comment form: <!- … -->  If a tag has attributes, they appear between its name and the right bracket Browsers ignore comments, unrecognizable tags, line breaks, multiple spaces, and tab</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>5</b></p> <a id="p6" href="#"></a> <h2>Basic text formatting</h2> <h3>• Paragraph Elements: <p> • Line break tag <br /> • Heading <h1> , …, <h6></h3> <p>• <h4> is the default size • <h5> and <h6> use smaller font size</p> <h3>• Blockquote <blockquote> • Preformatted <pre></h3> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>6</b></p> <a id="p7" href="#"></a> <h3>•</h3> <h3><b>Font Styles and Sizes (can be nested)</b></h3> <p>• • • • •</p> <p><b>Boldface - Italics <i> Larger <big> Smaller <small> monospace <tt></b></p> <h3>•</h3> <h3><b>Superscripts and subscripts</b></h3> <p>• •</p> <p><b>Subscripts with <sub> Superscripts with <sup></b></p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>7</b></p> <a id="p8" href="#"></a> <p>• Character Entities</p> <p><i>Char Entity</i></p> <p>& & " < > ' ¼ ½ ¾  (space) < > " Double quote &apos Single quote ¼ Less than Greater than One quarter ½ ¾ °</p> <p><i>Meaning</i></p> <p>Ampersand One half Three quarters Degree   Non-breaking space • Horizontal rules <hr /></p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>8</b></p> <a id="p9" href="#"></a> <h3>Images</h3> <p>• GIF (Graphic Interchange Format) 8-bit color (256 different colors) • JPEG (Joint Photographic Experts Group) 24-bit color (16 million different colors) • Portable Network Graphics (PNG) • Images are inserted into a document with <img /> tag with the src attribute <img src = "comets.jpg" alt = "Picture of Comets" /></p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>9</b></p> <a id="p10" href="#"></a> <h3>Hypertext Links</h3> <p>• Hypertext is the essence of the Web • Both links (sometimes called sources) and targets (or anchors) of links are specified with the anchor tag (<a>) • A link is specified with the href (hypertext reference) attribute of <a> • The content of <a> is the visual link in the document e.g. <a href="http://physcomp1.wlu.ca/~hfan/cp102/schedule_cp102.html"></p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>10</b></p> <a id="p11" href="#"></a> <h3>Lists</h3> <p>Unordered lists  The list is the content of the <ul> tag  List elements are the content of the <li> tag Ordered lists  The list is the content of the <ol> tag  Each item in the display is preceded by a sequence value Nested lists   Any type list can be nested inside any type list The nested list must be in a list item</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>11</b></p> <a id="p12" href="#"></a> <h3>Tables</h3> <p>A table is a matrix of cells, each possibly having content  The cells can include almost any elemen A table is specified as the content of a <table> tag  A border attribute in the <table> tag specifies a border between the cells     The border attribute can be set to a number, which will be the border width Without the border attribute, the table will have no lines!</p> <p>The cellspacing attribute of <table> is used to specify the distance between cells in a table The cellpadding attribute of <table> is used to specify the spacing between the content of a cell and the inner walls of the cell Tables are given titles with the <caption> tag, which can immediately follow <table></p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>12</b></p> <a id="p13" href="#"></a> <p>Each row of a table is specified as the content of a <tr> tag  The row headings are specified as the content of a <th> tag  The contents of a data cell is specified as the content of a <td> tag A table can have two levels of column labels  If so, the colspan attribute must be set in the <th> tag to specify that the label must span some number of columns   If the rows have labels and there is a spanningcolumn label, the upper left corner must be made larger, using rowspan The align attribute controls the horizontal placement of the contents in a table cell   Values are left, right, and center (default) align is an attribute of <tr>, <th>, and <td> elements</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>13</b></p> <a id="p14" href="#"></a> <h3>Forms</h3> <p>A form is the usual way that information is gotten from a browser to a server    HTML has tags to create a collection of objects that implement this information gathering The form objects are called </p> <p><i>widgets</i></p> <p>checkboxes, submit). (e.g., radio buttons and When the Submit button of a form is clicked, the form’s values are sent to the server There are eight types of widgets. All of the widgets, or components of a form are defined in the content of a <form> tag  Many are created with the <input> tag The type attribute of <input> specifies the kind of widget being created</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>14</b></p> <a id="p15" href="#"></a> <p>The only required attribute of <form> is action, which specifies the URL of the application that is to be called when the Submit button is clicked. The method attribute of <form> specifies one of the two possible techniques of transferring the form data to the server, get and post.</p> <p><b><form method="get“ action="http://216.249.63.53/~hfan/cgi-bin/marks.cgi"> Enter the nine digits of your student ID number to retrieve your marks for CP102 <input type="password" name="Password" size="20" value=""> <input type="hidden" name="Course" size="20" value="mark102"> </form></b></p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>15</b></p> <a id="p16" href="#"></a> <h3><b>1. Text</b></h3> <p> Creates a horizontal box for text input</p> <p><b><input type = "text" name = "name" size = "30" /></b></p> <p> Default size is 20; it can be changed with the size attribute  If more characters are entered than will fit, the box is scrolled (shifted) left  If you don’t want to allow the user to type more characters than will fit, set maxlength, which causes excess input to be ignored</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>16</b></p> <a id="p17" href="#"></a> <h3><b>2. Checkboxes</b></h3> <p>     Collect multiple choice input <input type = "checkbox" name = "groceries" value = "milk" checked = "checked" /> Milk Every checkbox requires a value attribute, which is the widget’s value in the form data when the checkbox is ‘checked’ A checkbox that is not ‘checked’ contributes no value to the query string By default, no checkbox is initially ‘checked’ To initialize a checkbox to ‘checked’, the checked attribute must be set to "checked”</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>17</b></p> <a id="p18" href="#"></a> <h3>3. Radio Buttons</h3> <p> Created with radio button tag <input type = "radio" name = "age" value = "20-35" />  collections of checkboxes in which only one button can be ‘checked’ at a time  Every button in a radio button group MUST have the same name  If no button in a radio button group is ‘pressed’, the browser often ‘presses’ the first one</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>18</b></p> <a id="p19" href="#"></a> <h3>4. Menus</h3> <p>Created with selection tag <selection> <select name = "groceries"> <option> milk </option> <option> bread </option> <option> eggs </option> <option> cheese </option> </select> Menus that behave like checkboxes are specified by including the multiple attribute, which must be set to "multiple“ The name attribute of <select> is required If size is set to > 1 or if multiple is specified, the menu is displayed as a pop-up menu Each item of a menu is specified with an <option> tag, whose pure text content (no tags) is the value of the item</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>19</b></p> <a id="p20" href="#"></a> <h3>5. Text areas</h3> <p> created with <textarea>  Usually include the rows and cols attributes to specify the size of the text area  Default text can be included as the content of <textarea>  Scrolling is implicit if the area is overfilled</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>20</b></p> <a id="p21" href="#"></a> <h3>6. Reset and Submit buttons</h3> <p> Both are created with <input> <input type = "reset" value = "Reset Form"> <input type = "submit” value = "Submit Form">   Submit has two actions: 1. Encode the data of the form 2. Request that the server execute the server-resident program specified as the value of the action attribute of <form> A Submit button is required in every form</p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>21</b></p> <a id="p22" href="#"></a> <h3>7. Password</h3> <p><input type ="password" name="set_password" value="old_password” size="8" maxlength="8"></p> <h3>8. Hidden field</h3> <p><input type="hidden" name="username” value=“hfan"></p> <p><b><i>CP102 Module 7: HTML</i></b></p> <p><b>22</b></p> </div> </section> </div> </div> </div> </main> <footer> <div class="container mt-3"> <div class="row justify-content-between"> <div class="col"> <a href="/"> <img src="/theme/studyslide/static/logo-slideum.png" /> </a> </div> </div> <div class="row mt-3"> <ul class="col-sm-6 list-unstyled"> <li> <h6 class="mb-3">Company</h6> <li> <i class="fa fa-location-arrow"></i> Nicosia Constantinou Palaiologou 16, Palouriotissa, 1040 <li> <i class="fa fa-phone"></i> +357 64-733-402 <li> <i class="fa fa-envelope"></i> info@slideum.com </ul> <ul class="col-6 col-sm-3 list-unstyled"> <li> <h6 class="mb-3">Links</h6> <li> <a href="/about">About</a> <li> <a href="/contacts">Contact</a> <li> <a href="/faq">Help / FAQ</a> </ul> <ul class="col-6 col-sm-3 list-unstyled"> <li> <h6 class="mb-3">Legal</h6> <li> <a href="/terms">Terms of Service</a> <li> <a href="/privacy">Privacy policy</a> <li> <a href="/page.html?code=public.usefull.cookie">Cookie policy</a> <li> <a href="/page.html?code=public.usefull.disclaimer">Disclaimer</a> </ul> </div> <hr> <p>slideum.com © 2024, Inc. All rights reserved.</p> </div> </footer> <div class="modal directory" id="directory-modal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Directory</h5> <button class="close" type="button" data-dismiss="modal">×</button> </div> <div class="modal-body"></div> </div> </div> </div> <script src="/theme/common/static/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/theme/common/static/jquery_extra/dist/jquery-extra.js"></script> <script src="/theme/common/static/popper.js@1.16.1/dist/umd/popper.min.js"></script> <script src="/theme/common/static/bootstrap@4.6.0/dist/js/bootstrap.min.js"></script> <script> var __path_directory = [ ] !function __draw_directory(data, root, uuid) { var ul = $('<ul>', uuid && { id: 'category' + uuid, class: !__path_directory.includes(uuid) ? 'collapse' : null }); for (var item in data) { var li = $('<li>').appendTo(ul); if (item = data[item], item.children) { li.append('<a href=#category' + item.id + ' data-toggle=collapse>') __draw_directory(item.children, li, item.id); } else { li.append('<a href=' + item.url + '>'); } var a = $('> a', li).addClass('item').text(item.name) .append($('<a class="link fa fa-external-link" href=' + item.url + '>')); if (item.id === +__path_directory.slice(-1)) { a.addClass('active'); } /* if (item.id !== __path_directory[0]) { a.addClass('collapsed'); } */ } root.append(ul); } ([{"id":1,"name":"Food and cooking","url":"/catalog/Food+and+cooking","children":null},{"id":2,"name":"Education","url":"/catalog/Education","children":null},{"id":3,"name":"Healthcare","url":"/catalog/Healthcare","children":null},{"id":4,"name":"Real estate","url":"/catalog/Real+estate","children":null},{"id":5,"name":"Religion ","url":"/catalog/Religion+","children":null},{"id":6,"name":"Science and nature","url":"/catalog/Science+and+nature","children":null},{"id":7,"name":"Internet","url":"/catalog/Internet","children":null},{"id":8,"name":"Sport","url":"/catalog/Sport","children":null},{"id":9,"name":"Technical documentation","url":"/catalog/Technical+documentation","children":null},{"id":10,"name":"Travel","url":"/catalog/Travel","children":null},{"id":11,"name":"Art and Design","url":"/catalog/Art+and+Design","children":null},{"id":12,"name":"Automotive","url":"/catalog/Automotive","children":null},{"id":13,"name":"Business","url":"/catalog/Business","children":null},{"id":14,"name":"Government","url":"/catalog/Government","children":null}], $('#directory-aside')); var __root_directory = $('#directory-aside > ul'); $('#directory-aside') .on('show.bs.collapse', function() { //console.log('show.collapse') }) .on('hide.bs.collapse', function() { //console.log('hide.collapse') }); $('#directory-modal') .on('show.bs.modal', function() { $('[class$="body"]', this).prepend(__root_directory); }) .on('hide.bs.modal', function() { $('#directory-aside').prepend(__root_directory); }); $('.directory-mobile').on('click', function(e) { e.preventDefault(); }); $('.directory .link').on('click', function(e) { e.stopPropagation(); }); </script> <script> function scrollToViewport() { $('html, body').stop().animate( { scrollTop: $('.navbar').outerHeight() }, 1000); } setTimeout(scrollToViewport, 1000); $(window).on('orientationchange', scrollToViewport); $('[data-toggle="tooltip"]').tooltip(); </script> <script async src="//s7.addthis.com/js/300/addthis_widget.js#pubid=#sp('addthis_pub_id')"></script> <!-- Yandex.Metrika counter --> <script type="text/javascript"> (function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter28397281 = new Ya.Metrika({ id:28397281 }); } catch(e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f, false); } else { f(); } })(document, window, "yandex_metrika_callbacks"); </script> <noscript><div><img src="//mc.yandex.ru/watch/28397281" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <!-- /Yandex.Metrika counter --> <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" /> <style> @media screen and (max-width: 768px) { .cc-revoke { display: none; }} </style> <script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script> <script> window.addEventListener("load", function() { window.cookieconsent.initialise( { content: { href: "https://slideum.com/dmca" }, location: true, palette: { button: { background: "#fff", text: "#237afc" }, popup: { background: "#007bff" }, }, position: "bottom-right", revokable: true, theme: "classic", type: "opt-in" })}); </script> </body> </html>