HTML & CSS
HTML & CSS
Unit I [8 T + 8 P]
•Introduction web-documents: Static, Dynamic, Active •Web programming: client side and
server side scripting •HTML 5: Document Structure, Elements, Attributes, Types of Elements
and Attributes •Basic HTML Data types •Using HTML5 form elements: datalist, keygen, output,
progress, meter •File uploading using forms •Frameset and frames •CSS: External CSS, CSS3
•CSS Syntax •CSS Selector: Universal, Class, ID •Working with Lists and Tables •CSS ID and
Class •Navigation Bar •Image Gallery •Image Opacity
Unit II [8 T + 9 P]
•Javascript: Introduction •Client side programming, script tag, comments, variables •Including
JavaScript in HTML: head, body, external •Data types •Operators: Arithmetic, Assignment,
Relational, Logical •Conditional Statements, Loops, break and continue •Output functions: write,
writeln, popup boxes: prompt, alert, confirm •Functions: Built-in Global Functions: alert(),
prompt(), confirm(), isNan(), Number(), parseInt() •User Defined Functions •Calling Functions
with Timer •Events Familiarization: onLoad, onClick, onBlur, onSubmit, onChange •Document
Object Model (Concept) •Objects: String, Array, Date.
Unit III [10 T + 10 P]
•PHP: Introduction •Server side programming •Role of Web Server software •Including PHP
Script in HTML: head, body, external •Comments, Data types, variables and scope, echo and
print •Operators: Arithmetic, Assignment, Relational, Logical •Conditional Statements, Loops,
break and continue •User Defined Functions
Unit IV [8 T + 9 P]
•Working with PHP: Passing information between pages •HTTP GET and POST method
•Cookie, Session •String functions: strlen, strops, strstr, strcmp, substr, str_replace, string case
•Array constructs: array(), list() and foreach() •Header()
Unit V [10 T + 10 P]
•PHP & PostgreSQL: Features of PostgreSQL •data types •PostgreSQL commands •CREATE
DATABASE •CREATE TABLE •DESCRIBE TABLE (\d table_name or using
usinginformation_schema) •SELECT •SELECT INTO •CREATE AS •DELETE •UPDATE
•INSERT •PHP - PostgreSQL Integration •Establishing Database Connection (pg_connect(),
pg_connection_status(), pg_dbname()) •Getting Error String (pg_last_error()) •Closing database
•Connection (pg_close()) •Executing SQL statements (pg_query(), pg_execute()) •Retrieving
Data (pg_fetch_row(), pg_fetch_array(), pg_fetch_all(), pg_fetch_assoc(), pg_fetch_object(),
pg_num_rows(), pg_num_fields(), pg_affected_rows(), pg_num_rows(), pg_free_result())
•Insertion and Deletion of data using PHP •Displaying data from PostrgreSQL database in
webpage •Introduction to AJAX •Implementation of AJAX in PHP •Simple example for partial
page update
BCA5B09|Web Programming using PHP
Unit I
1. Introduction web-documents
a. WWW Overview
WWW stands for World Wide Web. A technical definition of the World Wide Web is: all
the resources and users on the Internet that are using the Hypertext Transfer Protocol
(HTTP). A broader definition comes from the organization that Web inventor Tim
Berners-Lee helped found, the World Wide Web Consortium (W3C). The World Wide
Web is the universe of network-accessible information, an embodiment of human
knowledge.
In simple terms, The World Wide Web is a way of exchanging information between
computers on the Internet, tying them together into a vast collection of interactive
multimedia resources. Internet and Web is not the same thing: Web uses internet to
pass over the information.
b. Evolution
World Wide Web was created by Timothy Berners Lee in 1989
at CERN in Geneva. World Wide Web came into existence as a proposal by him, to
allow researchers to work together effectively and efficiently at CERN. Eventually it
became World Wide Web.
c. Web browser
A web browser (commonly referred to as a browser) is a software application for
retrieving, presenting, and traversing information resources on the World Wide Web.
An information resource is identified by a Uniform Resource Identifier (URI/URL) and
may be a web page, image, video or other piece of content. Hyperlinks present in
resources enable users easily to navigate their browsers to related resources. The
major web browsers are Firefox, Google Chrome, Internet Explorer/Microsoft
Edge, Opera, and Safari. The first web browser was invented in 1990 by Sir Tim
Berners-Lee. Berners-Lee is the director of the World Wide Web Consortium (W3C),
which oversees the Web's continued development, and is also the founder of the World
Wide Web Foundation. His browser was called WorldWideWeb and later renamed
Nexus.
d. Web server
A web server is a computer system that processes requests via HTTP, the
basic network protocol used to distribute information on the World Wide Web. The term
BCA5B09|Web Programming using PHP
can refer to the entire system, or specifically to the software that accepts and
supervises the HTTP requests. The primary function of a web server is to store, process
and deliver web pages to clients. The communication between client and server takes
place using the Hypertext Transfer Protocol (HTTP). Pages delivered are most
frequently HTML documents, which may include images, stylesheets and scripts in
addition to text content.
e. Web hosting
Web hosting is a service that allows organizations and individuals to post a website or
web page onto the Internet. A web host, or web hosting service provider, is a business
that provides the technologies and services needed for the website or webpage to be
viewed in the Internet. Websites are hosted, or stored, on special computers called
servers. When Internet users want to view your website, all they need to do is type your
website address or domain into their browser. Their computer will then connect to your
server and your webpages will be delivered to them through the browser. Most hosting
companies require that you own your domain in order to host with them. If you do not
have a domain, the hosting companies will help you purchase one.
f. Web Pages
Web page is a document available on World Wide Web. Web Pages are stored on web
server and can be viewed using a web browser. A web page can contain huge
information including text, graphics, audio, video and hyperlinks. These hyperlinks are
the link to other web pages. Collection of linked web pages on a web server is known
as website. There is unique Uniform Resource Locator (URL) is associated with each
web page.
g. Static Web page
Static web pages are also known as flat or stationary web page. They are loaded on
the client’s browser as exactly they are stored on the web server. Such web pages
contain only static information. User can only read the information but can’t do any
modification or interact with the information. Static web pages are created using only
HTML. Static web pages are only used when the information is no more required to be
modified.
BCA5B09|Web Programming using PHP
A static web document resides in a file that it is associated with a web server. The author
of a static document determines the contents at the time the document is written.
Because the contents do not change, each request for a static document results in
exactly the same response.
h. Dynamic Web page
Dynamic web page shows different information at different point of time. It is possible
to change a potation of a web page without loading the entire web page. It has been
made possible using Ajax technology. A dynamic web document does not exist in a
predefined form. When a request arrives the web server runs an application program
that creates the document. The server returns the output of the program as a response
to the browser that requested the document. Because a fresh document is created for
each request, the contents of a dynamic document can vary from one request to
another.
SERVER-SIDE DYNAMIC WEB PAGE
It is created by using server-side scripting. There are server-side scripting parameters
that determine how to assemble a new web page which also includes setting up of
more client-side processing.
CLIENT-SIDE DYNAMIC WEB PAGE
It is processed using client side scripting such as JavaScript and then passed in
to Document Object Model (DOM).
BCA5B09|Web Programming using PHP
i. Active Web page
An active web document consists of a computer program that the server sends to the
browser and that the browser must run locally. When it runs, the active document
program can interact with the user and change the display continuously.
ADVANTAGES AND DISADVANTAGES OF EACH DOCUMENT TYPE
Advantages Disadvantages
Static Simplicity, reliability and efficient. inflexibility, it can be
The browser can place a copy in a inconvenient, time consuming
cache on a local disk. and costly to change static
documents
1. JavaScript
It is a prototype based scripting language. It inherits its naming conventions from
java. All java script files are stored in file having .js extension.
2. ActionScript
It is an object oriented programming language used for the development of
websites and software targeting Adobe flash player.
3. Dart
It is an open source web programming language developed by Google. It relies on
source-to-source compiler to JavaScript.
BCA5B09|Web Programming using PHP
4. VBScript
It is an open source web programming language developed by Microsoft. It is
superset of JavaScript and adds optional static typing class-based object oriented
programming.
c. Server-side Scripting
Server-side scripting acts as an interface for the client and also limit the user access the
resources on web server. It can also collect the user’s characteristics in order to
customize response. A server is a computer system that serves as a central repository
of data and programs and is shared by clients. The server-side environment that runs a
scripting language is a web server. A user's request is fulfilled by running a script
directly on the web server to generate dynamic HTML pages. This HTML is then sent to
the client browser. It is usually used to provide interactive web sites that interface to
databases or other data stores on the server. This is different from client-side scripting
where scripts are run by the viewing web browser, usually in JavaScript. The primary
advantage to server-side scripting is the ability to highly customize the response based
on the user's requirements, access rights, or queries into data stores.
SERVER-SIDE PROGRAMMING
Server-side programming is the general name for the kinds of programs which are run
on the Server.
Uses:
1. Process user input.
2. Display pages.
3. Structure web applications.
4. Interact with permanent storage (SQL, files).
Example Languages:
1. PHP
2. Python
3. ASP.Net in C#, C++, or Visual Basic.
4. Nearly any language (C++, C#, Java). These were not designed specifically for
the task, but are now often used for application-level web services.
Following table describes commonly used Server-Side scripting languages:
2. ActiveVFP
It is similar to PHP and also used for creating dynamic web pages. It uses
native Visual Foxpro language and database.
3. ASP.net
It is used to develop dynamic websites, web applications, and web services.
4. Java
Java Server Pages are used for creating dynamic web applications. The Java
code is compiled into byte code and run by Java Virtual Machine (JVM).
5. Python
It supports multiple programming paradigms such as object-oriented, and
functional programming. It can also be used as non-scripting language using third
party tools such as Py2exe or Pyinstaller.
6. PHP
PHP is a server scripting language, and a powerful tool for making dynamic and
interactive Web pages. PHP is a widely-used, free, and efficient alternative to
competitors such as Microsoft's ASP.
The <script>
In HTML5 the <script> tag is used for the practices for embedding JavaScript. For
example, it is related with the page loading speed.
<script src="js/scripts.js"></script>
Example
<!DOCTYPE HTML>
<html>
<head>
<title>Title of the document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
html, body {
height: 100%;
}
body {
display: flex;
flex-wrap: wrap;
margin: 0;
BCA5B09|Web Programming using PHP
}
.header-menu, footer {
display: flex;
align-items: center;
width: 100%;
}
.header-menu {
justify-content: flex-end;
height: 60px;
background: #1c87c9;
color: #fff;
}
h2 {
margin: 0 0 8px;
}
ul li {
display: inline-block;
padding: 0 10px;
list-style: none;
}
aside {
flex: 0.4;
height: 165px;
padding-left: 15px;
border-left: 1px solid #666;
}
section {
flex: 1;
padding-right: 15px;
}
footer {
padding: 0 10px;
background: #ccc;
}
</style>
</head>
<body>
BCA5B09|Web Programming using PHP
<header class="header-menu">
<nav>
<ul>
<li>Menu item</li>
<li>Menu item</li>
<li>Menu item</li>
</ul>
</nav>
</header>
<section>
<article>
<header>
<h2>Learn HTML</h2>
<small>Hyper Text Markup Language</small>
</header>
<p>Our free HTML tutorial for beginners will teach you HTML and how to create your
website from the scratch. HTML isn't difficult, so hoping you will enjoy learning.</p>
</article>
<article>
<header>
<h2>Start Quiz "HTML Basic"</h2>
<small>You can test your HTML skills with W3docs' Quiz.</small>
</header>
<p>You will get 5% for each correct answer for single choice questions. In multiple choice
question it might be up to 5%. At the end of the Quiz, your total score will be displayed.
Maximum score is 100%.</p>
</article>
</section>
<aside>
<h2>Our Books</h2>
<p>HTML</p>
<p>CSS</p>
<p>JavaScript</p>
<p>PHP</p>
</aside>
<footer>
<small>Company © W3docs. All rights reserved.</small>
BCA5B09|Web Programming using PHP
</footer>
</body>
</html>
HTML Paragraphs
HTML paragraphs are defined with the <p> tag:
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
This is a paragraph.
This is a paragraph.
This is a paragraph.
Note: Browsers automatically add some white space (a margin) before and after a
paragraph.
HTML Links
HTML links are defined with the <a> tag:
<!DOCTYPE html>
<html>
<body>
<a href="https://www.w3schools.com">This is a link</a>
</body>
</html>
BCA5B09|Web Programming using PHP
This is a link
The link's destination is specified in the href attribute. Attributes are used to provide
additional information about HTML elements.
Block-level Elements
A block-level element always starts on a new line and takes up the full width available
(stretches out to the left and right as far as it can). The <div> element is a block-level
element.
Examples of block-level elements:
<div>, <h1> - <h6>, <p>, <form>
Inline Elements
An inline element does not start on a new line and only takes up as much width as
necessary.
London
London is the capital city of England. It is the most populous city in the United Kingdom, with a
metropolitan area of over 13 million inhabitants.
BCA5B09|Web Programming using PHP
My Important Heading
<div class="cities">
<h2>London</h2>
<p>London is the capital of England. It is the most populous city in the United Kingdom, with a
BCA5B09|Web Programming using PHP
</body>
</html>
London
London is the capital of England. It is the most populous city in the United Kingdom, with a
metropolitan area of over 13 million inhabitants.
Standing on the River Thames, London has been a major settlement for two millennia, its
history going back to its founding by the Romans, who named it Londinium.
Paris
Paris is the capital and most populous city of France.
Situated on the Seine River, it is at the heart of the Île-de-France region, also known as the
région parisienne.
Within its metropolitan area is one of the largest population centers in Europe, with over 12
million inhabitants.
Tokyo
Tokyo is the capital of Japan, the center of the Greater Tokyo Area, and the most populous
metropolitan area in the world.
It is the seat of the Japanese government and the Imperial Palace, and the home of the
Japanese Imperial Family.
The Tokyo prefecture is part of the world's most populous metropolitan area with 38 million
people and the world's largest urban economy.
BCA5B09|Web Programming using PHP
My Important Heading
This is some important text.
HTML Frames
HTML frames are used to divide your browser window into multiple sections where each section
can load a separate HTML document. A collection of frames in the browser window is known as
a frameset. The window is divided into frames in a similar way the tables are organized into
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag. The <frameset> tag
defines how to divide the window into frames. The rows attribute of <frameset> tag defines
horizontal frames and cols attribute defines vertical frames. Each frame is indicated by <frame>
tag and it defines which HTML document shall open into the frame.
BCA5B09|Web Programming using PHP
<frameset> attributes
<frameset cols="25%,*,25%">
<frame src="frame_a.htm">
<frame>
<frame src="frame_c.htm">
</frameset>
<frameset rows="50%,*”>
<frame src="frame_a.htm">
<frame src="frame_c.htm">
</frameset>
Iframe Syntax
An HTML iframe is defined with the <iframe> tag:
<iframe src="URL"></iframe>
The src attribute specifies the URL (web address) of the inline frame page.
Iframe - Set Height and Width
Use the height and width attributes to specify the size of the iframe. The attribute values are
specified in pixels by default, but they can also be in percent (like "80%").
<iframe src="demo_iframe.htm" height="200" width="300"></iframe>
This page is
displayed in an
iframe
BCA5B09|Web Programming using PHP
This page is
displayed in an
iframe
With CSS, you can also change the size, style and color of the iframe's border:
<iframe src="demo_iframe.htm" style="border:2px solid grey;"></iframe>
This page is
displayed in an
iframe
The image size is specified in pixels: width="104" means 104 screen pixels wide.
The alt attribute specifies an alternative text to be used, when an image cannot be displayed.
The value of the attribute can be read by screen readers. This way, someone "listening" to the
webpage, e.g. a blind person, can "hear" the element.
Animated Images
The GIF standard allows animated images:
<img src="programming.gif" alt="Computer Man" style="width:48px;height:48px;">
Note that the syntax of inserting animated images is no different from non-animated images.
Image Floating
Use the CSS float property to let the image float to the right or to the left of a text:
<!DOCTYPE html>
BCA5B09|Web Programming using PHP
<html>
<body>
<p><strong>Float the image to the right:</strong></p>
<p><img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">
A paragraph with a floating image. A paragraph with a floating image. A paragraph with a floating image.
</p><p><strong>Float the image to the left:</strong></p>
<p><img src="smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px;">
A paragraph with a floating image. A paragraph with a floating image. A paragraph with a floating image.
</p>
<p>Please use the CSS float property. The align attribute is deprecated in HTML 4, and not supported in
HTML5.</p>
</body></html>
Please use the CSS float property. The align attribute is deprecated in HTML 4, and not supported in
HTML5.
Image Maps
Use the <map> tag to define an image-map. An image-map is an image with clickable
areas. The name attribute of the <map> tag is associated with the <img>'s usemap attribute
and creates a relationship between the image and the map. The <map> tag contains a
number of <area> tags, that defines the clickable areas in the image-map:
<!DOCTYPE html>
<html>
<body>
<p>Click on the sun or on one of the planets to watch it closer:</p>
<img src="planets.gif" alt="Planets" usemap="#planetmap" style="width:145px;height:126px;">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
BCA5B09|Web Programming using PHP
</map>
</body>
</html>
HTML Styles
<!DOCTYPE html>
<html>
<body>
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
BCA5B09|Web Programming using PHP
I am normal
I am red
I am blue
I am big
The HTML Style Attribute
Setting the style of an HTML element, can be done with the style attribute. The HTML style
attribute has the following syntax:
<tagname style="property:value;">
The property is a CSS property. The value is a CSS value.
This is a heading
This is a paragraph.
HTML Fonts
The font-family property defines the font to be used for an HTML element:
<!DOCTYPE html>
<html>
<body>
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
</body></html>
This is a heading
This is a paragraph.
HTML Text Size
The font-size property defines the text size for an HTML element:
<!DOCTYPE html>
<html>
<body>
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
</body>
</html>
This is a heading
This is a paragraph.
HTML Text Alignment
The text-align property defines the horizontal text alignment for an HTML element:
<!DOCTYPE html>
<html>
<body>
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
</body>
BCA5B09|Web Programming using PHP
</html>
Centered Heading
Centered paragraph.
HTML Text Formatting
<!DOCTYPE html>
<html>
<body>
<p><b>This text is bold</b></p>
<p><i>This text is italic</i></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p></body></html>
<html>
<body>
<p>Here is a quote from WWF's website:</p>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For 50 years, WWF has been protecting the future of nature.
The world's leading conservation organization,
WWF works in 100 countries and is supported by
1.2 million members in the United States and
close to 5 million globally.
</blockquote>
</body>
</html>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
esrever
HTML Computer Code Elements
<code>
var x = 5;
var y = 6;
document.getElementById("demo").innerHTML = x + y;
</code>
document.getElementById("demo").innerHTML = x + y;
</code>
</pre>
var x = 5;
var y = 6;
document.getElementById("demo").innerHTML = x + y;
With comments you can place notifications and reminders in your HTML:
Comments are also great for debugging HTML, because you can comment out HTML lines of
code, one at a time, to search for errors:
Conditional Comments
You might stumble upon conditional comments in HTML:
<!--[if IE 9]>
.... some HTML here ....
<![endif]-->
Conditional comments defines some HTML tags to be executed by Internet Explorer only.
Local Links
The example above used an absolute URL (A full web address). A local link (link to the same
web site) is specified with a relative URL (without http://www....).
The target attribute specifies where to open the linked document. The target attribute can have
one of the following values:
_blank - Opens the linked document in a new window or tab
_self - Opens the linked document in the same window/tab as it was clicked (this is
default)
_parent - Opens the linked document in the parent frame
_top - Opens the linked document in the full body of the window
framename - Opens the linked document in a named frame
This example will open the linked document in a new browser window/tab:
<a href="https://www.w3schools.com/" target="_blank">Visit W3Schools!</a>
Tip: If your webpage is locked in a frame, you can use target="_top" to break out of the frame:
<a href="https://www.w3schools.com/html/" target="_top">HTML5 tutorial!</a>
Image as Link
It is common to use images as links:
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0;">
</a>
Note: border:0; is added to prevent IE9 (and earlier) from displaying a border around the image
(when the image is a link).
Linking to Internal References
<a href=”#point1”>Internal reference<a>
<br>
<br>
<a id=”Point1”>
When you click the word “home page,” the index.html” page will be loaded into the same
window, replacing the current page.
Linking to External Web Site
< p >For more details <a href=”http://www.Google.com/”> Click here< /a >< /p >
Linking to Images
HTML allows images inside the <a>element. When you use an image, you should make sure
that the image gives a clear indication of where the link will take you.
<a href=”sample.html”><img src=”tulips.jpg”></a>
HTML <a> tag provides you option to specify an email address to send an email. While using
<a> tag as an email tag, you will use mailto: email address along with href attribute. Following is
the syntax of using mailto instead of using http.
<a href = "mailto: [email protected]">Send Email</a>
This code will generate the following link which you can use to send email. When user clicks this
link, it launches one Email Client (like Lotus Notes, Outlook Express etc.) installed on your
user's computer.
<link>: The <link> tag defines a link between a document and an external resource. The <link>
tag is used to link to external style sheets.
Example:
<head>
<link rel="stylesheet" type="text/css" href="theme.css">
</head>
Create a Bookmark
HTML bookmarks are used to allow readers to jump to specific parts of a Web page. Bookmarks
can be useful if your webpage is very long. To make a bookmark, you must first create the
bookmark, and then add a link to it. When the link is clicked, the page will scroll to the location
with the bookmark.
First, create a bookmark with the id attribute:
<h2 id="tips">Useful Tips Section</h2>
Then, add a link to the bookmark ("Useful Tips Section"), from within the same page:
<a href="#tips">Visit the Useful Tips Section</a>
Or, add a link to the bookmark ("Useful Tips Section"), from another page:
<a href="html_tips.html#tips">Visit the Useful Tips Section</a>
External Paths
External pages can be referenced with a full URL or with a path relative to the current web
page. This example uses a full URL to link to a web page:
BCA5B09|Web Programming using PHP
This example links to a page located in the html folder on the current web site:
<a href="/html/default.asp">HTML tutorial</a>
This example links to a page located in the same folder as the current page:
<a href="default.asp">HTML tutorial</a>
HTML Tables
An HTML table is defined with the <table> tag. Each table row is defined with the <tr> tag. A
table header is defined with the <th> tag. By default, table headings are bold and centered. A
table data/cell is defined with the <td> tag.
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Note: The <td> elements are the data containers of the table. They can contain all sorts of
HTML elements; text, images, lists, other tables, etc.
Adding a Border
If you do not specify a border for the table, it will be displayed without borders. A border is set
using the CSS border property:
table, th, td {
border: 1px solid black;
}
Remember to define borders for both the table and the table cells.
BCA5B09|Web Programming using PHP
Collapsed Borders
If you want the borders to collapse into one border, add the CSS border-collapse property:
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
Left-align Headings
By default, table headings are bold and centered. To left-align the table headings, use the
CSS text-align property:
th {
text-align: left;
}
<td>55577854</td>
<td>55577855</td>
</tr>
</table>
Adding a Caption
To add a caption to a table, use the <caption> tag:
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
Note: The <caption> tag must be inserted immediately after the <table> tag.
BCA5B09|Web Programming using PHP
HTML Lists
Unordered HTML List
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. The list items will
be marked with bullets (small black circles) by default:
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Coffee
Tea
Milk
Value Description
<ul style="list-style-type:disc">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Coffee
Tea
Milk
<ul style="list-style-type:circle">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
o Coffee
o Tea
o Milk
<ul style="list-style-type:square">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Coffee
Tea
Milk
<ul style="list-style-type:none">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Coffee
BCA5B09|Web Programming using PHP
Tea
Milk
Ordered HTML List
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. The list items will
be marked with numbers by default:
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
1. Coffee
2. Tea
3. Milk
Type Description
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
1. Coffee
2. Tea
3. Milk
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
A. Coffee
BCA5B09|Web Programming using PHP
B. Tea
C. Milk
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
a. Coffee
b. Tea
c. Milk
<ol type="I">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
I. Coffee
II. Tea
III. Milk
<ol type="i">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
i. Coffee
ii. Tea
iii. Milk
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Coffee
BCA5B09|Web Programming using PHP
Coffee
Tea
o Black tea
o Green tea
Milk
Note: List items can contain new list, and other HTML elements, like images and links, etc.
Horizontal Lists
HTML lists can be styled in many different ways with CSS. One popular way is to style a list
horizontally, to create a menu:
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
BCA5B09|Web Programming using PHP
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px;
text-decoration: none;
}
li a:hover {
background-color: #111111;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
HTML Forms
The HTML <form> element defines a form that is used to collect user input:
<form>
.
form elements
.
</form>
An HTML form contains form elements. Form elements are different types of input
elements, like text fields, checkboxes, radio buttons, submit buttons, and more.
BCA5B09|Web Programming using PHP
Text Input
<input type="text"> defines a one-line input field for text input:
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of a text field is 20 characters.
Male
Female
Other
Input Type Checkbox
<input type="checkbox"> defines a checkbox. Checkboxes let a user select ZERO or MORE
options of a limited number of choices.
BCA5B09|Web Programming using PHP
<form>
<input type="checkbox" name="vehicle1" value="Bike"> I have a bike
<input type="checkbox" name="vehicle2" value="Car"> I have a car
</form>
First name:
Mickey
Last name:
Mouse
Submit
<form action="/action_page.php">
First name:<br> <input type="text" name="firstname" value="Mickey"><br>
Last name:<br> <input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
<input type="reset">
</form>
First name:
Mickey
Last name:
Mouse
Submit Reset
If you change the input values and then click the "Reset" button, the form-data will be reset to
the default values.
If the action attribute is omitted, the action is set to the current page.
Note: GET must NOT be used when sending sensitive information! GET is best suited for short,
non-sensitive, amounts of data, because it has size limitations too.
BCA5B09|Web Programming using PHP
Note: type="color" is not supported in Internet Explorer 11 and earlier versions or Safari 9.1 and
earlier versions.
Input Type Date
The <input type="date"> is used for input fields that should contain a date. Depending on
browser support, a date picker can show up in the input field.
BCA5B09|Web Programming using PHP
<form>
Birthday:
<input type="date" name="bday">
</form>
<form>
Birthday (month and year):
<input type="month" name="bdaymonth">
</form>
Points:
BCA5B09|Web Programming using PHP
The <option> element defines an option that can be selected. By default, the first item in the
drop-down list is selected. To define a pre-selected option, add the selected attribute to the
option:
<option value="fiat" selected>Fiat</option>
Input Restrictions
Here is a list of some common input restrictions (some are new in HTML5):
Attribute Description
c. Attributes
HTML Attributes
Attributes provide additional information about HTML elements.
All HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name="value"
BCA5B09|Web Programming using PHP
...
</body>
</html>
The first two letters specify the language (en). If there is a dialect, use two more letters (US).
BCA5B09|Web Programming using PHP
HTML Attributes
Below is an alphabetical list of some attributes often used in HTML:
Attribute Description
alt Specifies an alternative text for an image, when the image cannot be displayed
This is heading 1
This is heading 2
This is heading 2
Example Explained
The mapOptions variable defines the properties for the map. The center property specifies
where to center the map (using latitude and longitude coordinates). The zoom property specifies
the zoom level for the map (try to experiment with the zoom level). The mapTypeId property
specifies the map type to display. The following map types are supported: ROADMAP,
SATELLITE, HYBRID, and TERRAIN.
The line: var map=new google.maps.Map(document.getElementById("map"), mapOptions);
creates a new map inside the <div> element with id="map", using the parameters that are
passed (mapOptions).
HTML5 Video
Before HTML5, a video could only be played in a browser with a plug-in (like flash). The
HTML5 <video> element specifies a standard way to embed a video in a web page.
<!DOCTYPE html>
<html>
<body>
<video width="400" controls>
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
BCA5B09|Web Programming using PHP
</video>
<p>Video courtesy of
<a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.
</p></body>
</html>
How it Works
The controls attribute adds video controls, like play, pause, and volume. It is a good idea to
always include width and height attributes. If height and width are not set, the page might flicker
while the video loads. The <source> element allows you to specify alternative video files which
the browser may choose from. The browser will use the first recognized format. The text
between the <video> and </video> tags will only be displayed in browsers that do not support
the <video> element.
The autoplay attribute does not work in mobile devices like iPad and iPhone.
HTML5 Audio
Before HTML5, audio files could only be played in a browser with a plug-in (like flash). The
HTML5 <audio> element specifies a standard way to embed audio in a web page.
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
MP3 audio/mpeg
OGG audio/ogg
BCA5B09|Web Programming using PHP
WAV audio/wav
<ul>
<li>Apple</li>
<li>Banana</li>
</ul>
</div>
</body>
</html>
server. When an HTML form is submitted, the browser will generate a key pair and store
the private key in the browser's local key storage and send the public key to the server.
Syntax
The basic syntax of the <keygen> tag is given with:
HTML: <keygen>; XHTML: <keygen />
BCA5B09|Web Programming using PHP
The <datalist> element specifies a set of pre-defined options for an <input> element. It can be
used to provide the quick choices for an input field like an "autocomplete" feature. Its not only
saves the time of a user but also reduces errors, because the user has less likelihood of making
a spelling mistake. The list attribute of the input element is used to bind it together with a datalist
element.
Syntax
The basic syntax of the <datalist> tag is given with:
HTML / XHTML: <datalist> ... </datalist>
<form action="/action_page.php"
oninput="x.value=parseInt(a.value)+parseInt(b.value)">
0
<input type="range" id="a" name="a" value="50">
100 +
<input type="number" id="b" name="b" value="50">
=
<output name="x" for="a b"></output>
<br><br>
<input type="submit">
</form>
Use the meter element to measure data within a given range (a gauge):
<meter value="2" min="0" max="10">2 out of 10</meter><br>
<meter value="0.6">60%</meter>
BCA5B09|Web Programming using PHP
form form_id Specifies one or more forms the <meter> element belongs to
optimum number Specifies what value is the optimal value for the gauge
Tip: Do not use this attribute as a validation tool. File uploads should be validated on the
server.
<marquee> tag
The HTML <marquee> tag is used for scrolling piece of text or image displayed either
horizontally across or vertically down your web site page depending on the settings.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML marquee Tag</title>
</head>
<body>
<marquee>This is basic example of marquee</marquee>
<marquee direction = "up">The direction of text will be from bottom to top.</marquee>
</body>
</html>
direction Up, down, left, right Defines the direction of scrolling the content.
blink Tag
The HTML <blink> tag is used to enclose a text to make it blink. This tag was supported by
Netscape and now this is obsolete.
<!DOCTYPE html>
<html>
<head>
<title>HTML blink Tag</title>
</head>
<body>
<blink>This text will blink in Netscape Version 5.0</blink>
</body>
</html>
Browser Support
Chrome Firefox IE Opera Safari Android
control the color of the text, the style of fonts, what background images or colors are
used as well as a variety of other effects.
Advantages of CSS
CSS saves time − You can write CSS once and then reuse same sheet in multiple
HTML pages.
Pages load faster − If you are using CSS, you do not need to write HTML tag attributes
every time. Just write one CSS rule of a tag and apply it to all the occurrences of that
tag.
Easy maintenance − To make a global change, simply change the style, and all
elements in all the web pages will be updated automatically.
CSS Syntax
A CSS comprises of style rules that are interpreted by the browser and then applied to
the corresponding elements in your document. A style rule is made of three parts
Selector − A selector is an HTML tag at which a style will be applied. This could be any
tag like <h1> or <table> etc.
Property − A property is a type of attribute of HTML tag. They could be color, border etc.
Value − Values are assigned to properties. For example, colorproperty can have value
either red or #F1F1F1 etc.
The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a CSS property name and a value, separated by a colon.A
CSS declaration always ends with a semicolon, and declaration blocks are surrounded
by curly braces.
Example
p{ color: red;
text-align: center; }
CSS Comments
Comments are used to explain the purpose of code. Comments are ignored by
browsers. A CSS comment starts with /* and ends with */. Comments can also span
multiple lines:
BCA5B09|Web Programming using PHP
Example
/* Single Line*/
/*Multiple Line*/
CSS Selectors
CSS selectors are used to "find" (or select) HTML elements based on their element
name, id, class, attribute, and more.
The element Selector
The element selector selects elements based on the element name.
Example
p { text-align: center;
color: red; }
The id Selector
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element should be unique within a page, so the id selector is used to select
one unique element. To select an element with a specific id, write a hash (#) character,
followed by the id of the element. An id name cannot start with a number!
Example
<head><style>
#para1 {
text-align: center;
color: red;
}
#para2 {
color: green;
}
</style></head><body>
<p id="para1">Hello</p>
<p id="para2">Good Morning</p>
</body></html>
.center {
text-align: center;
color: red;
}
Grouping Selectors
If you have elements with the same style definitions, like this:
BCA5B09|Web Programming using PHP
It will be better to group the selectors, to minimize the code. To group selectors,
separate each selector with a comma.
Example
<style>
h1, h2, p {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1>Hello!</h1>
<h2>Dear</h2>
<p>Minu</p>
</body>
</html>
Inserting CSS
There are three ways of inserting a style sheet:
External style sheet
Internal style sheet
Inline style
Example
BCA5B09|Web Programming using PHP
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Contents of myStyle.css
body { background-color: lightblue; }
h1 { color: navy; margin-left: 20px;}
Inline Styles
An inline style may be used to apply a unique style for a single element. To use inline
styles, add the style attribute to the relevant element. The style attribute can contain any
CSS property.
Example
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>
If some properties have been defined for the same selector (element) in different style
sheets, the value from the last read style sheet will be used.
Example
Assume that an external style sheet has the following style for the <h1> element:
h1 { color: navy; }
Then, assume that an internal style sheet also has the following style for the <h1>
element:
h1 { color: orange; }
If the internal style is defined after the link to the external style sheet, the <h1> elements
will be "orange":
Cascading Order
In some situations there is more than one style specified for an HTML element. In this
time all the styles will "cascade" into a new "virtual" style sheet by the following rules,
where number one has the highest priority:
Inline style (inside an HTML element)
External and internal style sheets (in the head section)
Browser default
So, an inline style (inside a specific HTML element) has the highest priority, which
means that it will override a style defined inside the <head> tag, or in an external style
sheet, or a browser default value.
CSS font
The CSS font properties define the font family, boldness, size, and the style of a text. In
CSS, there are two types of font family names:
generic family - a group of font families with a similar look (like "Serif" or
"Monospace")
font family - a specific font family (like "Times New Roman" or "Arial")
Times New Roman Serif fonts have small lines at the ends on
Serif
Georgia some characters
Font Properties
Property Description
font-family property
The font-family property is used to specify the font. If the name of a font family is more
than one word, it must be in quotation marks, like: "Times New Roman". More than one
font family is specified in a comma-separated list:
font-family: "Times New Roman", Times, serif;
font-style property
The font-style property is used to specify the style of a font. This property has three
values:
normal - The text is shown normally
italic - The text is shown in italics
oblique - The text is "leaning" (oblique is very similar to italic, but less supported)
p.normal { font-style: normal;}
font-size property
BCA5B09|Web Programming using PHP
The font-size property is used to set the size of the text. If you do not specify a font
size, the default size for normal text, like paragraphs, is 16px (16px=1em).
Set Font Size With Em
To allow users to resize the text (in the browser menu), many developers use em
instead of pixels. The em size unit is recommended by the W3C. 1em is equal to the
current font size. The default text size in browsers is 16px. So, the default size of 1em is
16px. The size can be calculated from pixels to em using this formula: pixels/16=em
h1 { font-size: 2.5em; /* 40px/16=2.5em */}
font-weight property
The font-weight property specifies the weight of a font. Values are normal and bold.
h1{ font-weight: normal;}
h1{ font-weight: bold; }
font-variant property
The font-variant property specifies whether or not a text should be displayed in a small-
caps font. In a small-caps font, all lowercase letters are converted to uppercase letters.
Converted uppercase letters appears in a smaller font size than the original uppercase
letters in the text.
Example
h1{ font-variant: normal; }
h1{ font-variant: small-caps;}
Property Description
color property
The color property is used to set the color of the text.
Values are
a color name - like "red"
a HEX value - like "#ff0000"
an RGB value - like "rgb(255,0,0)"
h1 { color: green; }
direction property
The direction property is used to change the text direction of an element:
Values are
ltr : The writing direction is left-to-right. This is default
rtl : The writing direction is right-to-left
div { direction: rtl; }
text-align property
The text-align property specifies the horizontal alignment of text in an element.
Values are
Left : left alignment
Right : right alignment
center : center alignment
justify : combination of left and right alignment
h1 { text-align: center;}
text-decoration property
The text-decoration property specifies the decoration added to text. Values are
None : Defines a normal text. This is default
Underline : Defines a line below the text
Overline : Defines a line above the text
line-through : Defines a line through the text
BCA5B09|Web Programming using PHP
text-transform property
The text-transform property controls the capitalization of text. Values are
none : No capitalization. This is default
capitalize : Transforms the first character of each word to uppercase
uppercase : Transforms all characters to uppercase
lowercase : Transforms all characters to lowercase
p.uppercase { text-transform: uppercase;}
Background Property
The CSS background properties are used to define the background effects for
elements.
Property Description
background-attachment Sets whether a background image is fixed or scrolls with the rest of the page
background-color Sets the background color of an element
background-image Sets the background image for an element
background-position Sets the starting position of a background image
background-repeat Sets how a background image will be repeated
It is possible to specify all the background properties in one single property. This is
called a shorthand property.
body { background: #ffffff url("img_tree.png") no-repeat right top;}
When using the shorthand property the order of the property values is:
background-color
background-image
background-repeat
background-attachment
background-position
background-color property
The background-color property specifies the background color of an element. Values
are
a valid color name - like "red"
a HEX value - like "#ff0000"
BCA5B09|Web Programming using PHP
background-image property
The background-image property specifies an image to use as the background of an
element. By default, the background-image property repeats an image both horizontally
and vertically.
body { background-image: url("paper.gif"); }
When using a background image, use an image that does not disturb the text.
background-repeat property
background-repeat property is used to repeat an image only horizontally or vertically.
Values are
repeat-y : To repeat an image vertically set background-repeat: repeat-y;
repeat-x: To repeat an image horizontally set background-repeat: repeat-x;
no-repeat : To display background image only once set background-repeat: no-
repeat;
body { background-image: url("gradient_bg.png");
background-repeat: repeat-x; }
background-position property
The position of the image is specified by the background-position property. Values are
left top
left center
left bottom
right top
right center
right bottom
center top
center center
center bottom.
body {
background-image: url("img_tree.png");
background-position: right top; }
BCA5B09|Web Programming using PHP
background-attachment property
To specify that the background image should be fixed (will not scroll with the rest of the
page), use the background-attachment property. Values are
scroll : The background scrolls along with the element. This is default
fixed: The background is fixed with regard to the viewport
body {
background-image: url("img_tree.png");
background-attachment: fixed; }
Specifies if the list-item markers should appear inside or outside the content
list-style-position
flow
list-style-image property
The list-style-image property specifies an image as the list item
ul { list-style-image: url('sqpurple.gif'); }
list-style-position property
The list-style-position property specifies whether the list-item markers should appear
inside or outside the content flow. Values are inside and outside.
ul { list-style-position: inside;}
list-style-type property
The list-style-type property specifies the type of list item marker. The following example
shows some of the available list item markers:
BCA5B09|Web Programming using PHP
list-style property
The list-style property is a shorthand property. It is used to set all the list properties in
one.
ul { list-style: square inside url("sqpurple.gif"); }
When using the shorthand property, the orders of the property values are:
list-style-type (if a list-style-image is specified, the value of this property will be
displayed if the image for some reason cannot be displayed)
list-style-position (specifies whether the list-item markers should appear inside or
outside the content flow)
list-style-image (specifies an image as the list item marker)
If one of the property values above is missing, the default value for the missing property
will be inserted, if any.
CSS Table
Table is used to display the text in cells.
CSS Table Properties
Property Description
border property
border property is used to set all the border properties in one declaration.
table { border: 1px solid black;}
table, th, td { border: 1px solid black;}
The border shorthand property sets all the border properties in one declaration. The
properties that can be set, are (in order): border-width, border-style, and border-color.
border-collapse property
The border-collapse property sets whether the table borders should be collapsed into a
single border.
table { border-collapse: collapse;}
border-spacing property
The border-spacing property specifies the distance between the borders of adjacent
cells
table {
border-collapse: separate;
border-spacing: 10px 50px;
}
caption-side property
The caption-side property is used to specify the placement of a table caption.
caption { caption-side: bottom;}
Horizontal Alignment
The CSS Text property text-align sets the horizontal alignment (like left, right, or center)
of the content in <th> or <td>. By default, the content of <th> elements are center-
aligned and the content of <td> elements are left-aligned.
th { text-align: left;}
Vertical Alignment
The CSS Text property vertical-align sets the vertical alignment (like top, bottom, or
middle) of the content in <th> or <td>. By default, the vertical alignment of the content in
a table is middle (for both <th> and <td> elements).
td {
height: 50px;
vertical-align: bottom;
}
Table Padding
To control the space between the border and the content in a table, use the CSS
Padding property padding with <td> and <th> elements: The padding property is a
shorthand property for the following individual padding properties:
padding-top
padding-right
padding-bottom
padding-left
th, td {
padding: 15px;
text-align: left;
}
Horizontal Dividers
Add the border-bottom property to <th> and <td> for horizontal dividers. The border-
bottom shorthand property sets all the bottom border properties in one declaration. The
properties in order are:
border-bottom-width, border-bottom-style and border-bottom-color
th, td { border-bottom: 1px solid #ddd;}
BCA5B09|Web Programming using PHP
Table Color
To change table color use CSS background property background-color and text color of
<th> elements:
th {
background-color: yellow;
color: white;
}
Specifies what to do with the left/right edges of the content if it overflows the
overflow-x
element's content area
Specifies what to do with the top/bottom edges of the content if it overflows the
overflow-y
element's content area
position property
The position property specifies the type of positioning method used for an element.
There are four different position values:
static
relative
fixed
absolute
Elements are then positioned using the top, bottom, left, and right properties. However,
these properties will not work unless the position property is set first. They also work
differently depending on the position value.
BCA5B09|Web Programming using PHP
position: static;
HTML elements are positioned static by default. Static positioned elements are not
affected by the top, bottom, left, and right properties. An element with position: static; is
not positioned in any special way; it is always positioned according to the normal flow of
the page:
div.static { position: static; }
position: relative;
An element with position: relative; is positioned relative to its normal position. Setting
the top, right, bottom, and left properties of a relatively-positioned element will cause it
to be adjusted away from its normal position. Other content will not be adjusted to fit into
any gap left by the element.
div.relative {
position: relative;
left: 30px;
}
position: fixed;
An element with position fixed is positioned relative to the viewport, which means it
always stays in the same place even if the page is scrolled. The top, right, bottom, and
left properties are used to position the element. Fixed element is positioned in the lower-
right corner of the page.
div.fixed {
position: fixed;
bottom: 0;
right: 0;
width: 300px;
}
position: absolute;
An element with position: absolute is positioned relative to the nearest positioned
ancestor. if an absolute positioned element has no positioned ancestors, it uses the
document body, and moves along with page scrolling.
div.relative {
position: relative;
width: 400px;
height: 200px;
BCA5B09|Web Programming using PHP
Overlapping Elements
When elements are positioned, they can overlap other elements. The z-index property
specifies the stack order of an element (which element should be placed in front of, or
behind, the others). An element can have a positive or negative stack order. Because
the image has a z-index of -1, it will be placed behind the text.
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1; }
If two positioned elements overlap without a z-index specified, the element positioned
last in the HTML code will be shown on top
Specifies on which sides of an element where floating elements are not allowed to
clear
float
Specifies what to do with the left/right edges of the content if it overflows the
overflow-x
element's content area
Specifies what to do with the top/bottom edges of the content if it overflows the
overflow-y
element's content area
BCA5B09|Web Programming using PHP
float property
The float property specifies whether or not an element should float.
img { float: right; }
Value Description
none The element is not floated, and will be displayed just where it occurs in the text. This is default
clear Property
The clear property is used to control the behavior of floating elements. Elements after a
floating element will flow around it. To avoid this, use the clear property. The clear
property specifies on which sides of an element floating elements are not allowed to
float:
Value Description
both No floating elements allowed on either the left or the right side
overflow property
The overflow property specifies what happens if content overflows an element's box.
Value Description
visible The overflow is not clipped. It renders outside the element's box. This is default
hidden The overflow is clipped, and the rest of the content will be invisible
scroll The overflow is clipped, but a scroll-bar is added to see the rest of the content
auto If overflow is clipped, a scroll-bar should be added to see the rest of the content
div {
width: 150px; height: 150px;
overflow: scroll;
}
BCA5B09|Web Programming using PHP
image gallery
CSS can be used to create an image gallery.
The opacity property can take a value from 0.0 - 1.0. The lower value, the image is
more transparent.
Image Sprites
An image sprite is a collection of images put into a single image. A web page with many
images can take a long time to load and generates multiple server requests. Using
image sprites will reduce the number of server requests and save bandwidth. Instead of
using three separate images, we use this single image ("img_navsprites.gif"):
#home {
width: 46px;
height: 44px;
background: url(img_navsprites.gif) 0 0; }