Web Programming Chapter II (HTML&CSS)
Web Programming Chapter II (HTML&CSS)
line break:
inserts a new line
Format: <br>
E.g. line one <br> line two <br> line three <br> line four
26
</table> Web Programming Dec 18, 2023
HTML Tags (cont’d)
E.g.
<table>
<caption align=“center” valign=“bottom”>table 1.0</caption>
<tr>
<th>Column 1</th> <th>Column 2</th>
</tr>
<tr>
<td>Cell 1</td> <td>Cell2</td>
</tr>
<tr>
<td>Cell 3</td> <td>Cell 4</td>
</tr>
27
</table> Web Programming Dec 18, 2023
HTML Tags (cont’d)
Table attributes:
align=“alignment” {left, center, right}
bgcolor=“color”
width=“table width” {absolute or relative}
border=“border width”
bordercolor=“color”
cellspacing=“space amount” {in pixels}
cellpadding=“padding amount” {in pixels}
…
E.g. (colspan)
<table border=“1”>
<tr> <td colspan=“2”>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> </tr>
<tr> <td>Cell 4</td> <td>Cell 5</td> <td>Cell 6</td> <td>Cell 7</td> </tr>
<tr> <td colspan=“4”>Cell 8</td> </tr>
</table>
E.g. (hybrid)
<table>
<tr> <th colspan=“3”>Title</th> </tr>
<tr> <th rowspan=“3”>Cell 1</th> <td>Cell 2</td> <td>Cell 3</td> </tr>
<tr> <td>Cell 4</td> <td>Cell 5</td> </tr>
<tr> <td>Cell 6</td> <td>Cell 7</td> </tr>
</table>
31 Web Programming Dec 18, 2023
HTML Special Characters
Special characters (named characters)
not found on the standard keyboard
e.g. ©
used by HTML
e.g. <
ignored by browsers
e.g. blank spaces
Format:
&code;
Examples:
© © < < & & space
Tags
Ex.
<form method=“post” action=“search.php”>
….
</form>
Attributes:
name=“name”
type=“type”
{text, hidden, password, file, submit, reset, button, checkbox, radio,
image}
value=“value”
disabled=“disabled”
checked=“checked”
Attributes:
name=“name”
cols=“num_columns”
rows=“num_rows”
readonly=“readonly”
wrap=“wrap_type” {off, hard, soft, virtual, physical}
Ex.
1. <select name=“department”>
<option value=“1”>Computer Science</option>
<option value=“2”>Information Science</option>
<option value=“3”>Computer Engineering</option>
</select>
2. Modify the above input so that Information Science is selected by
default.
Ex.
<label>First Name:
<input type=“text” name=“fname”>
</label>
Attributes:
<legend>
align=“alignment” {left, center, right}
the table borders can be set to 0 so that they are not visible
other features of tables (rows & columns) can be adjusted as
required
Exercises:
New Semantic Elements – Some new elements such as <header>, <footer> and
<section> are added to HTML5.
Forms 2.0 – The web forms are improved by introducing some new attributes for
the <input> tag.
Persistent Local Storage – This storage is achieved without resorting to the third-
party plugins.
Server–Sent Events – Events introduced by HTML5 which flow from the web
servers to the web browsers and they are known as Server-Sent Events(SSE).
Canvas – It is a drawing surface which supports two-dimensional drawing that can
be programmed with JavaScript.
Audio & Video - Audios and videos can be added to the web pages without
resorting to the third-party plugins.
Geolocation - Physical location of the visitors can be shared with the web
applications.
Drag and drop – This feature helps in dragging and dropping items from one
location to the other on the same web page.
53 Web Programming Dec 18, 2023
HTML5-Rules
New features should be based on HTML, CSS, DOM, and
JavaScript
The need for external plug-ins (like Flash) needs to be
reduced
Error handling should be easier than in previous versions
Scripting has to be replaced by more markup
HTML5 should be device-independent
The development process should be visible to the public
<!DOCTYPE html>
<html>
<body>
</body>
</html>
2. Embedded/Global/Internal Style Sheets
Same CSS syntax rules for assigning and invoking style properties
apply
Browser defaults
External styles
Embedded styles
Inline styles
HTML5 attributes
CSS (cont’d)
CSS styles can be specified:
Inside a single HTML element (inline)
Inside the <head> element of an HTML document (internal)
In an external CSS file (external)
Format:
1. Styles for a particular element
Syntax: tag_name.style_name { property: value }
Ex. p.color { color: green }
<p class=“color”>some text</p>
2. Styles for all elements
Syntax: .style_name { property: value }
Ex. .color { color: blue }
<div class=“color”>some text</div>
86 Web Programming Dec 18, 2023
<table class=“color”>…</table>
CSS (cont’d)
The Id selector
unlike the class selector, the Id selector always applies to only
one element
Format:
1. Styles for a particular element
Syntax: tag_name#style_name { property: value }
Ex. p#color { color: green }
<p id=“color”>some text</p>
2. Styles for all elements
Syntax: #style_name { property: value }
Ex. #color { color: blue }
<div id=“color”>some text</div>
87 <table id=“color”>…</table> possible
Web Programming Dec 18,???
2023
CSS (cont’d)
CSS comments
Format:
/* comment text */
Example
p{
color: red; /* Set text color to red */
/* This is
a multi-line
comment */
}
Background
background-color: color
background-image: url(url)
background-repeat: repeat_type {repeat, repeat-x, repeat-y, no-repeat}
background-attachment: attachment_type {scroll, fixed}
Text
color: color
direction: direction {ltr, rtl} borwser issue??
letter-spacing: value
text-align: alignment {left, right, center, justify}
text-decoration: decoration {none, underline, overline, line-through,
blink}
text-indent: value
h1 {
CSS rule applying to color: black;
a single element.
font-size: 12pt;
font-family: arial;
}
h1, h2, p {
CSS rule applying to color: red;
a three elements. font-size: 12pt;
font-family: arial;
}
CSS Example