Chapter 2 Introduction To HTML
Chapter 2 Introduction To HTML
Chapter-2
Introduction t o HT M L
1
Chapter Contents
2
Content Without Markup
Without HTML markup to describe content structure, text runs together; line breaks are ignored:
The Restaurant
The Black Goose Bistro offers casual lunch
and dinner fare in a relaxed atmosphere. The
menu changes regularly to highlight the
freshest local ingredients.
Catering
You have fun. We'll handle the cooking. Black
Goose Catering can handle events from snacks
for a meetup to elegant corporate
fundraisers.
<!DOCTYPE html>
<html>
<head>
</body>
</html>
HTML-Example Explained
HTML Tags and Element
HTML Tags
• Attributes are typically specified within the opening tag of an HTML element
using the following syntax:
<element attribute="value">Content</element>
Example
<div>
<h1>Headline</h1>
<p>This is <em>emphasized</em> text.</p>
</div>
Tools we need to write H T M L code
1.Text editor to write Html code and create html files. Examples:
• Note pad.
• Itom
• Visual studio code
• Sublime
• Notepad++(windows)
• Text Mate (Mac)
2.Web browser
The purpose of a web browser (Chrome, Edge, Firefox) is to read
HTML documents and display them correctly
<head> element
• The <head> Contains information about the HTML document.
• The HTML <head> element is a container for other elements like:
<title>, <meta>, <style>, <link>, <script>
• The <title> element defines the title of the document.
• The <title> element is used inside the <head> element.
</body>
</html>
Paragraph <p> element
Text between <!-- and --> won’t display in the browser. Keep in mind
that they are still visible in the source.
Horizontal Lines <hr> element
<!DOCTYPE html>
<html>
<head>
<title>HTML hr Tag</title>
</head>
<body>
<p>This text will be followed by a horizontal line </p>
<hr >
</body>
</html>
HTML line Break
• Inserting Images into Web Pages can improve the design and the appearance
of a web page.
<img src="url" alt="alternate text">
For example, to create a link to the Bisha university home page, you would use
the following code:
Orange
Apple
Banana
Ordered List
Nested List
item 1
item 2
o sub-item 2.1
o sub-item 2.2
item 3
Definition List
• In definition lists the entries are listed like a dictionary.
• The definition list is the ideal way to present a glossary, list of terms, or other name/value list.
• Definition List makes use of following three tags.
HTML
This stands for Hyper Text Markup
Language
HTTP
This stands for Hyper Text Transfer
Protocol
HTML table
<table> element defines the start and end of the table.
<caption> element defines the caption of the table.
<thead> element defines the header row(s) of the table.
<th>Within the header row, data is displayed in individual cells
using the
<tbody> element defines the body of the table.
<tr> element defines the row in the table.
• (for header cells).
<td> Within each body row, and footer row, data is displayed in
individual cells using the (for data cells).
HTML table
HTML table allows you to arrange data into rows and columns.
Span of columns and rows
COLSPAN
COLSPAN Sets the number of columns this cell will occupy.
<TABLE BORDER=1>
<TR><TH COLSPAN=“2”>Col 1&2 Heading</TH>
<TH>Col3 Heading</TH>
</TR>
<TR><TD>Col1 Data</TD>
<TD>Col2 Data</TD>
<TD>Col3 Data</TD>
</TABLE>
ROWSPAN
ROWSPAN Sets the number of rows this cell will occupy.
HTML forms
An HTML form is used to collect user input.
form elements
</form>
Elements inside<form>:
• If you want to make a radio button or checkbox selected by default, youcan add the
checked attribute to the input element:
• <input type="checkbox" checked>.
CheckBox
• Checkboxes allows the user to select one or more option from a pre-
defined set of options.
• If you want to make a radio button or checkbox selected by default, youcan add the
checked attribute to the input element:
• <input type="checkbox" checked>.
Submit and Reset
• A submit button is used to send the form data to a web server.
• When submit button is clicked the form data is sent to the file
specified in the form's action attribute to process the submitted data.
• A reset button resets all the forms control to default values.
Disabled Specifies that an input field <input type="text" name="firstname" value="John" disabled>
should be disabled
Max Specifies the maximum value <input type="number" name="quantity" min="1" max="5">
for an input field
Min Specifies the minimum value <input type="number" name="quantity" min="1" max="5">
for an input field
• <label for="address">Address:</label>
• <textarea rows="3" cols="30" name="address"id="address"></textarea>
<select> element for dropdown list
<label for="city">City:</label>
<select name="city" id="city">
<option value="sydney">Sydney</option>
<option value="melbourne">Melbourne</option>
<option value="cromwell">Cromwell</option>
</select>
Grouping Form Elements
To add the video to the HTML page, we use the <video> tag.
In this example, we have set the width and height of the video player to320px
and 240px, respectively.
The controls attribute adds basic playback controls such as play, pause,and
volume controls.
The <source> tag specifies the location of the video file, and the type
attribute specifies the format of the video
Adding Audio
To add the video to the HTML page, we use the <audio> tag.
<audio controls>
<source src="audioFile.mp3" type="audio/mpeg">
</audio>
The controls attribute adds a set of controls to the audio player such as play, pause, and
volume controls.
The <source> tag specifies the location of the audio file, and the type attribute specifies the
type of the audio file.
Block and Inline element
Block element
• A block-level element always starts on a new line.
• A block-level element always takes up the full width available.
• A block level element has a top and a bottom margin, whereas an inline element does
not.
• Examples: <h1> to<h6>, <p>, <ol>,<ul>,<div>etc.
Inline element
• An inline element does not start on a new line.
• An inline element only takes up as much width as necessary.
Examples: <a>, <img>,<b>,<i>,<u>,<input> <span>, etc.
<div> element
• The <div> tag is known as Division tag.
• The <div> tag is generally used by web developers to
group HTML elements together and apply CSS styles to
many elements at once.
<div >
<h2>This is a heading in a div element</h2>
<p>This is some text in a div element.</p>
</div>
Thank You
46