Presentation is loading. Please wait.

Presentation is loading. Please wait.

CP102 Module 7: HTML 1 Module 7: HTML 1.What is 1.What is HTML? 2. 2.Basic syntax, document structure 3. 3.Basic formatting, images, links 4. 4.Lists,

Similar presentations


Presentation on theme: "CP102 Module 7: HTML 1 Module 7: HTML 1.What is 1.What is HTML? 2. 2.Basic syntax, document structure 3. 3.Basic formatting, images, links 4. 4.Lists,"— Presentation transcript:

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

2 2 CP102 Module 7: HTML What is HTML What is HTML? HyperText Markup Language (HTML) is an Markup Language for marking up WWW documents 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 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 Publish documents to the Internet in a format not dependent on platform Present text, graphics and multimedia data Present text, graphics and multimedia data Create links pointing to other WWW documents Create links pointing to other WWW documents

3 3 CP102 Module 7: HTML 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 HTML2.0, 1995 => HTML3.2, 1997 HTML 4.0, 1997=>HTML 4.01, in 1999 HTML4.01 HTML 4.0, 1997=>HTML 4.01, in 1999 HTML4.01 XHTML1.0, 2000 => XML (eXtensible Markup Language) 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)

4 4 CP102 Module 7: HTML Standard HTML document structure <html><head> …… ……..…………………...………………….<body></html> The whole document must have as its root The whole document must have as its root A document consists of a head and a body 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 The tag is used to give the document a title, which is normally displayed in the browser’s window title bar

5 5 CP102 Module 7: HTML Tag and elements Tags are markups to tell browser how to display it’s contents. Tags are markups to tell browser how to display it’s contents. An element: tags and its marked contents An element: tags and its marked contents Tag format: Opening tag Opening tag Closing tag Closing tag Not case sensitive 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 If a tag has no content, its form is If a tag has attributes, they appear between its name and the right bracket If a tag has attributes, they appear between its name and the right bracket Every tag that has content must have a closing tag Tags must be properly nested Every tag that has content must have a closing tag Tags must be properly nested Comment form: Comment form: Browsers ignore comments, unrecognizable tags, line breaks, multiple spaces, and tab Browsers ignore comments, unrecognizable tags, line breaks, multiple spaces, and tab Basic Syntax

6 6 CP102 Module 7: HTML Paragraph Elements: Paragraph Elements: Line break tag Line break tag Heading, …, Heading, …, is the default size is the default size and use smaller font size and use smaller font size Blockquote Blockquote Preformatted Preformatted Basic text formatting

7 7 CP102 Module 7: HTML Font Styles and Sizes (can be nested)Font Styles and Sizes (can be nested) Boldface - Boldface - Italics Italics Larger Larger Smaller Smaller monospace monospace Superscripts and subscriptsSuperscripts and subscripts Subscripts with Subscripts with Superscripts with Superscripts with

8 8 CP102 Module 7: HTML Character Entities Char EntityMeaning &&ampAmpersand &gtGreater than "&quotDouble quote '&aposSingle quote ¼&frac14One quarter ½&frac12One half ¾&frac34Three quarters  &degDegree (space) &nbspNon-breaking spaceCharacter Entities Char EntityMeaning &&ampAmpersand &gtGreater than "&quotDouble quote '&aposSingle quote ¼&frac14One quarter ½&frac12One half ¾&frac34Three quarters  &degDegree (space) &nbspNon-breaking space Horizontal rules Horizontal rules

9 9 CP102 Module 7: HTML Images GIF (Graphic Interchange Format) 8-bit color (256 different colors)GIF (Graphic Interchange Format) 8-bit color (256 different colors) JPEG (Joint Photographic Experts Group) 24-bit color (16 million different colors)JPEG (Joint Photographic Experts Group) 24-bit color (16 million different colors) Portable Network Graphics (PNG)Portable Network Graphics (PNG) Images are inserted into a document withImages are inserted into a document with tag with the src attribute tag with the src attribute

10 10 CP102 Module 7: HTML Hypertext Links Hypertext Links Hypertext is the essence of the WebHypertext is the essence of the Web Both links (sometimes called sources) and targets (or anchors) of links are specified with the anchor tag ( )Both links (sometimes called sources) and targets (or anchors) of links are specified with the anchor tag ( ) A link is specified with the href (hypertext reference) attribute of A link is specified with the href (hypertext reference) attribute of The content of is the visual link in the document e.g.The content of is the visual link in the document e.g.

11 11 CP102 Module 7: HTML Lists Unordered lists The list is the content of the tag The list is the content of the tag List elements are the content of the tag List elements are the content of the tag Ordered lists The list is the content of the tag The list is the content of the tag Each item in the display is preceded by a sequence value Each item in the display is preceded by a sequence value Nested lists Any type list can be nested inside any type list Any type list can be nested inside any type list The nested list must be in a list item The nested list must be in a list item

12 12 CP102 Module 7: HTML Tables A table is a matrix of cells, each possibly having content The cells can include almost any elemen The cells can include almost any elemen A table is specified as the content of a tag A border attribute in the tag specifies a border between the cells A border attribute in the tag specifies a border between the cells The border attribute can be set to a number, which will be the border width 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! Without the border attribute, the table will have no lines! The cellspacing attribute of is used to specify the distance between cells in a table The cellspacing attribute of is used to specify the distance between cells in a table The cellpadding attribute of is used to specify the spacing between the content of a cell and the inner walls of the cell The cellpadding attribute of 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 tag, which can immediately follow Tables are given titles with the tag, which can immediately follow

13 13 CP102 Module 7: HTML Each row of a table is specified as the content of a tag The row headings are specified as the content of a tag The row headings are specified as the content of a tag The contents of a data cell is specified as the content of a tag The contents of a data cell is specified as the content of a tag A table can have two levels of column labels If so, the colspan attribute must be set in the tag to specify that the label must span some number of columns If so, the colspan attribute must be set in the 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 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 The align attribute controls the horizontal placement of the contents in a table cell Values are left, right, and center (default) Values are left, right, and center (default) align is an attribute of,, and elements align is an attribute of,, and elements

14 14 CP102 Module 7: HTMLForms 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 HTML has tags to create a collection of objects that implement this information gathering The form objects are called widgets (e.g., radio buttons and checkboxes, submit). The form objects are called widgets (e.g., radio buttons and checkboxes, submit). When the Submit button of a form is clicked, the form’s values are sent to the server 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 tag Many are created with the tag The type attribute of specifies the kind of widget being created Many are created with the tag The type attribute of specifies the kind of widget being created

15 15 CP102 Module 7: HTML The only required attribute of is action, which specifies the URL of the application that is to be called when the Submit button is clicked. The method attribute of specifies one of the two possible techniques of transferring the form data to the server, get and post. Enter the nine digits of your student ID number to retrieve your marks for CP102 Enter the nine digits of your student ID number to retrieve your marks for CP102 </form>

16 16 CP102 Module 7: HTML 1. Text Creates a horizontal box for text input Creates a horizontal box for text input Default size is 20; it can be changed with the size attribute 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 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 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

17 17 CP102 Module 7: HTML 2. Checkboxes Collect multiple choice input <input type = "checkbox" name = "groceries" Collect multiple choice input <input type = "checkbox" name = "groceries" value = "milk" checked = "checked" /> Milk 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’ 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 A checkbox that is not ‘checked’ contributes no value to the query string By default, no checkbox is initially ‘checked’ By default, no checkbox is initially ‘checked’ To initialize a checkbox to ‘checked’, the checked attribute must be set to "checked” To initialize a checkbox to ‘checked’, the checked attribute must be set to "checked”

18 18 CP102 Module 7: HTML 3. Radio Buttons Created with radio button tag Created with radio button tag collections of checkboxes in which only one button can be ‘checked’ at a time 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 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 If no button in a radio button group is ‘pressed’, the browser often ‘presses’ the first one

19 19 CP102 Module 7: HTML 4. Menus Created with selection tag Created with selection tag milk milk bread bread eggs eggs cheese cheese Menus that behave like checkboxes are specified by including the multiple attribute, which must be set to "multiple“ The name attribute of 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 tag, whose pure text content (no tags) is the value of the item

20 20 CP102 Module 7: HTML 5. Text areas created with created with Usually include the rows and cols attributes to specify the size of the text area Usually include the rows and cols attributes to specify the size of the text area Default text can be included as the content of Default text can be included as the content of Scrolling is implicit if the area is overfilled Scrolling is implicit if the area is overfilled

21 21 CP102 Module 7: HTML 6. Reset and Submit buttons Both are created with Both are created with Submit has two actions: 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 2. Request that the server execute the server-resident program specified as the value of the action attribute of A Submit button is required in every form A Submit button is required in every form

22 22 CP102 Module 7: HTML 7. Password 7. Password 8. Hidden field


Download ppt "CP102 Module 7: HTML 1 Module 7: HTML 1.What is 1.What is HTML? 2. 2.Basic syntax, document structure 3. 3.Basic formatting, images, links 4. 4.Lists,"

Similar presentations


Ads by Google