HTML
HTML
Year: 2023-24
Semester: 3 Course Code: 22CS2305
Module 1
Markup Language (HTML5): Introduction to HTML and HTML5 - Formatting and Fonts -Commenting
Code – Anchors – Backgrounds – Images – Hyperlinks – Lists – Tables – HTML Forms, Audio ,Video
Tag
DEEPAK H G
ASST. PROF.
DEPT. OF CSE
INTRODUCTION
• Text Editor
• Notepad - Windows
• Notepad++ - Windows
• TextEdit – Mac
• Web Browser
• Mozilla Firefox
• Google Chrome
• Microsoft Edge
• Safari
HTML PAGE STRUCTURE
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
HTML PAGE STRUCTURE
• <!DOCTYPE html>
• Defines that the document is an HTML5 document.
• <html>
• Root element of an HTML page. Defines the whole HTML document.
• <head>
• Contains meta information about the HTML page.
• <body>
• Container for visible content.
HTML ELEMENT
• Element
• The HTML element is everything from the start tag to the end tag.
• <tagname>content</tagname>.
• Elements can have attributes.
• Attributes provide additional information about the elements.
• Always specified in the start tag.
• Come in name /value pairs: name = “value”
• Empty Element
• Elements with no content.
• Do not have an end tag.
• HTML tags are not case sensitive. Recommended to use lowercase in HTML.
• Never skip the end tag.
• Recommended to use quotes around attribute values.
• Double quotes around attribute values are the most common.
• Single quotes can also be used.
• When attribute value itself contains double quotes, it is necessary to use single quotes.
FIRST HTML PAGE – OPEN TEXT EDITOR
• Windows
• Open the Start Screen. Type Notepad. Click to open.
• Mac
• Open Finder > Applications > TextEdit
• In Preferences > Format > Plain Text.
• Under Open and Save, check the box that says "Display HTML files as HTML code instead
of formatted text".
• Open the new document.
FIRST HTML PAGE – WRITE HTML
FIRST HTML PAGE – SAVE THE FILE
• The <br> element defines a line break (a new line), without starting a new paragraph.
HTML TEXT FORMATTING
• The HTML <strong> element defines the text with strong importance.
• The text is displayed in bold.
HTML TEXT FORMATTING – ITALIC TEXT
• The HTML element <mark> defines the text that is marked or highlighted.
HTML TEXT FORMATTING – SMALLER TEXT
• The HTML <del> element defines the text deleted from a document.
• Browser strike a line through the deleted text.
HTML TEXT FORMATTING – INSERTED TEXT
• The HTML <ins> element defines the text that has been inserted into a document.
• Browser underline the inserted text.
HTML TEXT FORMATTING – SUBSCRIPT TEXT
• The HTML <blockquote> element defines a section that is quoted from another source.
• Usually browsers indent the <blockquote> elements.
HTML QUOTATION AND CITATION ELEMENTS
• The HTML <address> element defines the address for the author/owner of a document
or article.
• The contact information can be an email, URL, physical address, phone number social
media handle etc.
• The text is usually rendered in italic, and the browser always add a line break before and
after the <address> element.
HTML QUOTATION AND CITATION ELEMENTS
HTML QUOTATION AND CITATION ELEMENTS
• The HTML <cite> defines the title of a creative work like a book, a poem, a song etc..
• The text in the <cite> element is rendered in italic.
BI-DIRECTIONAL OVERRIDE
• The HTML <bdo> element is used to override the current text direction.
• BDO stands for Bi-Directional Override.
HTML COMMENTS
• URLs
• Address indicating the location of a file or resource on the World Wide Web.
• Absolute URL
• The complete address of the document on the internet.
• Relative URL
• Address of the document relative to the current document or directory.
HTML LINKS - HYPERLINKS
HTML LINKS – LINK TO AN EMAIL ADDRESS
• Use the mailto: inside the href attribute to create a link that opens the user’s email
program.
• This lets the user to send an email.
HTML LINKS – LINK TO AN EMAIL ADDRESS
HTML IMAGES
• To define the table cells as header cells, use <th> and </th> tag instead of <td> and
</td> tag.
HTML TABLES
HTML TABLES – BORDER ATTRIBUTE
HTML TABLES – TABLE CAPTION
• HTML table can have cells that span over multiple rows and/or columns
HTML TABLES – COLSPAN AND ROWSPAN
• To make a cell span over multiple rows, use the rowspan attribute.
• The value of the rowspan attribute represents the number of rows to span.
• To make a cell span over multiple columns, use the colspan attribute.
• The value of the colspan attribute represents the number of columns to span.
HTML TABLES – COLSPAN AND ROWSPAN
HTML CHARACTER ENTITIES
• Block-level Element
• Always starts on a new line and takes up the full available width of the browser.
• Browser adds a margin before and after the element.
• Commonly used block elements are:
• <p>
• <div>
HTML BLOCK ELEMENTS
HTML INLINE ELEMENTS
HTTP Request
HTTP Response
HTML FORMS
HTML FORMS
• The HTML <form> element can contain one or more of the following elements:
• <label>
• <input>
• <select>
• <textarea>
• <button>
• <fieldset>
• <legend>
• <datalist>
• <output>
• <option>
• <optgroup>
HTML FORM ELEMENTS - INPUT
• Set the for attribute of the <label> element equal to the id attribute of the <input>
element to bind them together.
• Click on the label text in the browser.
HTML FORM ELEMENTS – INPUT TYPE PASSWORD
• The <input type=“submit”> defines a button for submitting the form data to a
form-handler.
• The form-handler is typically a page at the server with a code for processing the data.
HTML FORM ELEMENTS – INPUT TYPE IMAGE
• The <input type=“reset”> defines a reset button that resets the form values to their
default.
WORKING OF A WEB APPLICATION
HTTP Request
HTTP Response
HTML FORM ATTRIBUTES
GET POST
Appends the form data to the URL in name=value Appends the form data inside the body of the
pairs. HTTP request.
NEVER use GET to send sensitive data as Always use POST if the form data contains
the data is visible in the URL. sensitive or personal information.
The length of a URL is limited (2048 characters). POST has no size limitations, and can be used to
send large amounts of data.
Useful for form submissions where a user wants Form submissions with POST cannot be
to bookmark the result. bookmarked.
HTML FORM ATTRIBUTES
• <input type=“color”> is used for input fields that should contain a color.
• A color picker shows up in the input field.
HTML FORM ELEMENTS – INPUT TYPE DATE
• The <input type=“date”> is used for input fields that should contain a date.
• Depending upon the browser, a date picker shows up in the input field.
HTML FORM ELEMENTS – INPUT TYPE DATE
• The <input type=“time”> allows the user to select a time (no time zone).
• Depending upon the browser, a time picker shows up in the input field.
HTML FORM ELEMENTS – INPUT TYPE WEEK
• The <input type=“week”> allows the user to select a week and year.
• Depending upon the browser, a date picker shows up in the input field.
HTML FORM ELEMENTS – INPUT TYPE EMAIL
• The <input type=“email”> is used for input fields that should contain an e-mail address.
• Depending on the browser support, the e-mail address will be validated on form
submission.
• Smartphones may recognize the email type and add ".com" to the keyboard to match
email input.
HTML FORM ELEMENTS – INPUT TYPE FILE
• The <input type=“file”> defines a file-select field and a Browse button for file uploads.
HTML FORM ELEMENTS – INPUT TYPE FILE
• The <input type=“hidden”> defines a hidden (not visible to user) input field.
• It is visible using browser’s developer’s tools or View Source functionality.
• To include data that can’t be seen or modified by users.
HTML FORM ELEMENTS – INPUT TYPE NUMBER
• The <input type=“number”> is used for input fields that should contain numerical value.
• Use min and max attributes to add restrictions on what numbers are accepted.
• The <input type=“range”> defines a control for entering a number whose exact value
is not important (Similar to slider control).
• Default range is 0 to 100.
• Restrict the range using min, max and step attributes.
HTML FORM ELEMENTS – INPUT TYPE SEARCH
• The <input type=“tel”> is used for input fields that should contain a telephone number.
• The pattern attribute is the JavaScript regular expression that the input value must match.
• Required Format in the example: 123-45-678
HTML FORM ELEMENTS – INPUT TYPE URL
• The <input type=“url”> is used for input fields that should contain a URL address.
• Depending on browser support, the url field can be automatically validated when
submitted.
• Smartphones may recognize the url type, and add ".com" to the keyboard to match url
input.
HTML FORM ELEMENTS – SELECT ELEMENT
• The <datalist> element specifies a list of pre-defined options for an <input> element.
• User sees a drop-down list of the pre-defined options as they input the data.
• The list attribute of the <input> element must refer the id attribute of the <datalist>
element.
HTML FORM ELEMENTS – OUTPUT ELEMENT
• The HTML <audio> element is used to play an audio file on a web page.
• The controls attribute adds audio controls like play, pause and volume.
• The source element specifies the audio files which the browser may choose from. The browser use the
first recognized format, if there are many.
• The text between <audio></audio> will only be displayed if the browser don’t support <audio> element.
HTML AUDIO
• The source element specifies the video files which the browser may choose from. The browser use the first
recognized format, if there are many.
• The text between <video></ video > will only be displayed if the browser don’t support <audio> element.
HTML VIDEO