WT Unit - 2notes
WT Unit - 2notes
AND ENGINEERING
Web Technology
B20EF0501
For
Seventh Semester
B. Tech in Computer Science and Engineering
Web Application Development AY 2021-2022
Web Technology
-Syllabus
Prerequisites:
Programming with Java (B18CS3030) and Database Management System (B18CS4030).
Course Description:
The basics of Web application tools such as HTML, XHTML and CSS are introduced. The
course also provides knowledge about advanced research topics such as Javascript and PHP.
Course Objectives:
1. Explain the basic concepts of HTML code.
2. Illustrate the use of Cascading Style Sheets in web pages.
3. Demonstrate the Java Scripts syntax and Forms in real world applications.
4. Describe the principles of object oriented development and database concept using PHP.
Course Contents:
Unit- 1
Introduction to HTML, HTML Syntax, Semantic Markup, Structure of HTML Documents,
HTML Elements, HTML Semantic Structure Elements, HTML Web Storage. HTML Tables and
Forms, Introducing Tables, Styling Tables, Introducing Forms, Form Control Elements, Table
and Form Accessibility, Micro formats
Unit -2
Introduction to CSS, What is CSS, CSS Syntax, Location of Styles, Selectors, The Cascade:
How Styles Interact, CSS Text Styling. Advanced CSS: Layout, Normal Flow, Positioning
Elements, Floating Elements, Constructing Multicolumn Layouts, Approaches to CSS Layout,
Responsive Design, CSS Frameworks.
Unit- 3
2
Web Application Development AY 2021-2022
JavaScript: Client-Side Scripting, JavaScript’s History and Uses, JavaScript Design Principles,
Where Does JavaScript Go? Syntax, Control statements, Functions, JavaScript Objects,
Constructors, The Document Object Model (DOM), JavaScript Events, Forms.
Unit- 4
Introduction to server-side Development with PHP,Arrays and Superglobals, Arrays, $GET and
$POST Superglobal Arrays, $_SERVER Array, $_Files Array, Reading/Writing Files, PHP
Classes and Objects, Object-Oriented Overview, Classes and Objects in PHP, Object Oriented
Design, Working with Databases, SQL, Database APIs, Managing a MySQL Database.
Accessing MySQL in PHP.
Self-learning component:
HTML5,JQuery,XML, Ruby, Introduction to REST and RESTful API
3
Web Application Development AY 2021-2022
Unit -2
Introduction to CSS
1.What Is CSS?
At various places in the previous chapter on HTML, it was mentioned that in current web
development best practices HTML should not describe the formatting or presentation of
documents. Instead that presentation task is best performed using Cascading Style Sheets
(CSS).
CSS is a W3C standard for describing the appearance of HTML elements.Another common way
to describe CSS’s function is to say that CSS is used to define the presentation of HTML
ocuments. With CSS, we can assign font properties, colors, sizes, borders, background images,
and even position elements on the page.CSS can be added directly to any HTML element (via
the style attribute), within the <head> element, or, most commonly, in a separate text file that
contains only CSS.
Benefits of CSS
The benefits of CSS include:
■ Improved control over formatting. The degree of formatting control in CSS is significantly
better than that provided in HTML. CSS gives web authors fine-grained control over the
appearance of their web content.
■ Improved site maintainability. Websites become significantly more maintainable because all
formatting can be centralized into one CSS file, or a small handful of them. This allows you to
make site-wide visual modifications by changing a single file.
■ Improved accessibility. CSS-driven sites are more accessible. By keeping presentation out of
the HTML, screen readers and other accessibility tools work better, thereby providing a
significantly enriched experience for those reliant on accessibility tools.
■ Improved page download speed. A site built using a centralized set of CSS files for all
presentation will also be quicker to download because each individual HTML file will contain
less style information and markup, and thus be smaller.
■ Improved output flexibility. CSS can be used to adopt a page for different output media. This
approach to CSS page design is often referred to as responsive design.
CSS Versions
Just like with the previous chapter, we should say a few words about the history of CSS. Style
sheets as a way to visually format markup predate the web. In the early 1990s, a variety of
different style sheet standards were proposed, including JavaScript style sheets, which was
proposed by Netscape in 1996. Netscape’s proposal was one that required the use of JavaScript
programming to perform style changes. Thankfully for nonprogrammers everywhere, the W3C
decided to adopt CSS, and by the end of 1996 the CSS Level 1 Recommendation was published.
4
Web Application Development AY 2021-2022
A year later, the CSS Level 2 Recommendation (also more succinctly labeled simply as CSS2)
was published.4 Even though work began over a decade ago, an updated version of the Level 2
Recommendation, CSS2.1, did not become an official W3C Recommendation untilJune 2011.
And to complicate matters even more, all through the last decade (and to the present day as
well), during the same time the CSS2.1 standard was being worked on, a different group at the
W3C was working on a CSS3 draft. To make CSS3 more manageable for both browser
manufacturers and web designers, the W3C has subdivided it into a variety of different CSS3
modules. So far the following CSS3 modules have made it to official W3C Recommendations:
CSS Selectors, CSS Namespaces, CSS Media Queries, and CSS Color.
2.CSS Syntax
A CSS document consists of one or more style rules. A rule consists of a selector that identifies
the HTML element or elements that will be affected, followed by a series of property:value
pairs (each pair is also called a declaration),.The series of declarations is also called the
declaration block. The browser ignores white space (i.e., spaces, tabs, and returns) between
your CSS rules so you can format the CSS however you want. Notice thateach declaration is
terminated with a semicolon. The semicolon for the last declaration in a block is in fact optional.
3.Location of Styles
5
Web Application Development AY 2021-2022
Embedded style sheets (also called internal styles) are style rules placed within the <style>
element (inside the <head> element of an HTML document).
<head>
<meta charset="utf-8">
<title>Share Your Travels -- New York - Central Park</title>
<style>
h1 { font-size: 24pt; }
h2 {
font-size: 18pt;
font-weight: bold;
}
</style>
</head>
<body>
...
4.Selectors
6
Web Application Development AY 2021-2022
Element Selectors
Element selectors select all instances of a given HTML element. The example CSS rules in.
You can select all elements by using the universal element selector, which is the * (asterisk)
character.You can select a group of elements by separating the different element names with
commas. This is a sensible way to reduce the size and complexity of your CSS files, by
combining multiple identical rules into a single rule.
Class Selectors
A class selector allows you to simultaneously target different HTML elements regardless of
their position in the document tree. If a series of HTML elements have been labeled with the
same class attribute value, then you can target them for styling by using a class selector, which
takes the form: period (.) followed by the class name.
<head>
<title>Share Your Travels </title>
<style>
.first {
font-style: italic;
color: red;
}
</style>
</head>
<body>
<h1 class="first">Reviews</h1>
<div>
<p class="first">By Ricardo on <time>2016-05-23</time></p>
<p>Easy on the HDR buddy.</p>
</div>
<hr/>
<div>
7
Web Application Development AY 2021-2022
Id Selectors
An id selector allows you to target a specific element by its id attribute regardless of its type or
position. If an HTML element has been labeled with an id attribute,
<head>
<title>Share Your Travels </title>
<style>
#latestComment {
font-style: italic;
color: red;
}
</style>
</head>
<body>
<h1 class="first">Reviews</h1>
<div id="latestComment">
<p class="first">By Ricardo on <time>2016-05-23</time></p>
<p>Easy on the HDR buddy.</p>
</div>
<hr/>
<div>
<p class="first">By Susan on <time>2016-11-18</time></p>
<p>I love Central Park.</p>
</div>
<hr/>
</body>
8
Web Application Development AY 2021-2022
Attribute Selectors
An attribute selector provides a way to select HTML elements either by the presence of an
element attribute or by the value of an attribute. This can be a very powerful technique, but
because of uneven support by some of the browsers, not all web authors have used them.
Attribute selectors can be a very helpful technique in the styling of hyperlinks and images. For
instance, perhaps we want to make it more obvious to the user when a pop-up tooltip is available
for a link or image. We can do this by using the following attribute selector:
[title] { … }
This will match any element
<head>
<meta charset="utf-8">
<title>Share Your Travels</title>
<style>
[title] {
cursor: help;
padding-bottom: 3px;
border-bottom: 2px dotted blue;
text-decoration: none;
}
</style>
</head>
<body>
<div>
<img src="images/flags/CA.png" title="Canada Flag" />
<h2><a href="countries.php?id=CA" title="see posts from Canada”> Canada</a></h2>
<p>Canada is a North American country consisting of … </p>
<div>
<img src="images/square/6114907897.jpg” title="At top of Sulphur Mountain" />
<img src="images/square/6592317633.jpg” title="Grace Presbyterian Church" />
<img src="images/square/6592914823.jpg” title="Calgary Downtown" />
</div>
</div>
9
Web Application Development AY 2021-2022
</body>
Selector Matches
[] A specific attribute.
[=] A specific attribute with a specific value.
[~=] A specific attribute whose value matches
at least one of the words in a space delimited
list of words.
[^=] A specific attribute whose value begins
with a specified value.
[*=] A specific attribute whose value contains
a substring.
[$=] A specific attribute whose value ends
with a specified value.
10
Web Application Development AY 2021-2022
selector. A pseudo-class selector does apply to an HTML element, but targets either a particular
state or, in CSS3, a variety of family relationships.
• a:link
• a:visited
• :focus
• :hover
• :active
• :checked
• :first-child
• :first-letter
• :first-line
The most common use of this type of selectors is for targeting link states. By default, the browser
displays link text blue and visited text links purple.
<style>
a:link {
text-decoration: underline;
color: blue;
}
a:visited {
text-decoration: underline;
color: purple;
}
a:hover {
text-decoration: none;
font-weight: bold;
}
a:active {
background-color: yellow;
}
</style>
Contextual Selectors
A contextual selector (in CSS3 also called combinators) allows you to select elements based on
their ancestors, descendants, or siblings. That is, it selects elements based on their context or
their relation to other elements in the document tree. While some of these contextual selectors
are used relatively infrequently, almost all web authors find themselves using descendant
selectors.
A descendant selector matches all elements that are contained within another element. The
character used to indicate descendant selection is the space character.
11
Web Application Development AY 2021-2022
The “Cascade” in CSS refers to how conflicting rules are handled. The visual metaphor behind
the term cascade is that of a mountain stream progressing downstream over rocks (and not that
of a popular dishwashing detergent). The downward movement of water down a cascade is
meant to be analogous to how a given style rule will continue to take precedence with child .CSS
12
Web Application Development AY 2021-2022
uses the following cascade principles to help it deal with conflicts: inheritance,specificity, and
location.
Inheritance
Inheritance is the first of these cascading principles. Many (but not all) CSS properties affect
not only themselves but their descendants as well. Font, color, list, and text properties are
inheritable; layout, sizing, border, background, and spacing properties are not.
In the first example, only some of the property rules are inherited for the <body> element. That
is, only the bodyelement (thankfully!) will have a thick green border and the 100-px margin;
however,all the text in the other elements in the document will be in the Arial font and colored
red.
13
Web Application Development AY 2021-2022
In the second example you can assume there is no longer the body styling but instead we have a
single style rule that styles all the <div> elements. The <p> and <time> elements within the
<div> inherit the bold font-weight property but not the margin or border styles.
Specificity
Specificity is how the browser determines which style rule takes precedence when more than one
style rule could be applied to the same element.
14
Web Application Development AY 2021-2022
Location
Finally, when inheritance and specificity cannot determine style precedence, the principle of
location will be used. The principle of location is that when rules have the same specificity, then
the latest are given more weight. For instance, an inline style will override one defined in an
external author style sheet or an embedded style sheet.
15
Web Application Development AY 2021-2022
16
Web Application Development AY 2021-2022
Borders
Borders provide a way to visually separate elements. You can put borders around all four sides
of an element, or just one, two, or three of the sides.
Border widths are perhaps the one exception to the general advice against using the pixel
measure. Using em units or percentages for border widths can result in unpredictable widths as
the different browsers use different algorithms (some round up, some round down) as the zoom
level increases or decreases. For this reason, border widths are almost always set to pixel units.
17
Web Application Development AY 2021-2022
18
Web Application Development AY 2021-2022
Property Description
font A combined shorthand property that allows you to set the family, style,
size, variant, and weight in one property.
style weight variant size font-family
font-family Specifies the typeface/font to use. More than one can be specified.
font-size The size of the font in one of the measurement units
font-style Specifies whether italic, oblique, or normal
font-weight Specifies either normal, bold, bolder, lighter, or a value between 100 and
900 in multiples of 100, where larger number represents
weightier (i.e., bolder) text.
Paragraph Properties
Just as there are properties that affect the font in CSS, there are also a range of CSS properties
that affect text independently of the font.
• letter-spacing
• line-height
• text-align
• text-decoration
• text-direction
• text-shadow
• …
Just look at text-shadow
19
Web Application Development AY 2021-2022
In general, it is better to use <strong> … </strong> than <b> …</b>, and it is better to use
<em> …</em> than <i> … </i>. (‘em’ stands for emphasis.) This is because readers for the
visually impaired can render ‘strong’ and ‘em’ but not b(old) and i(talics).
Font manipulation
Fonts have a font-face (e.g. Arial, Courier, etc.), a font-size, font-weight (e.g. bold), a font-
style (e.g. italic).
Text attributes are used to set alignment (text-align), color (text-color) and decoration
(text-decoration can have the values underline, overline, line-through or blink).
To have a paragraph in bold red with the Arial font and in the font three times as large as
usual you would write:
<p style=”font-face:Arial; font-weight:bold; font-size:3em;text-color:red”> …</p>
20
Web Application Development AY 2021-2022
The <font> tage of XHTML1 and HTML4 is no longer available in (X)HTML5. Accordingly,
you may no longer use code such as:
<font> </font> …….. Font tags
These tags are used to specify a particular font - size, face, color in the body.
Size, face and color are the attributes (properties) you are specifying in the font tag.
When the font tag closes, those attributes end.
You may also specify the typeface - but the face must be available on the user's
computer.
face="Times, times, Times Roman, times roman, Times New Roman, times new roman"
will look for these 6 faces (in that order), and then go to the default face.
Colors:
Finally, you may specify colors. You should always try to use browser-safe colors.
Colors are described by a set of three hexadecimal numbers. Each of the numbers is of
the form hh.
Since there are three such numbers, the whole thing looks like hhhhhh.
Each of the h's is 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, or F.
The three numbers specify the level of the Red, Green and Blue lights which
make up the whole color.
21
Web Application Development AY 2021-2022
The following list of colors is in the transitional but not the strict DTD of XHTML1 and is
also available for styling with CSS (hence in HTML5).
There are also 16 widely known color names with their RGB values:
22