WT 18cs62 Module 1
WT 18cs62 Module 1
APPLICATIONS
Dept of CSE
MITE, Moodbidri
Syllabus
• Module – 1
Introduction to HTML, What is HTML and Where
did it come from?, HTML Syntax, Semantic
Markup, Structure of HTML Documents, Quick
Tour of HTML Elements, HTML5 Semantic
Structure Elements, Introduction to CSS, What is
CSS, CSS Syntax, Location of Styles, Selectors, The
Cascade: How Styles Interact, The Box Model, CSS
Text Styling.
• Module – 2
HTML Tables and Forms, Introducing Tables, Styling
Tables, Introducing Forms, Form Control Elements,
Table and Form Accessibility, Microformats, Advanced
CSS: Layout, Normal Flow, Positioning Elements,
Floating Elements, Constructing Multicolumn Layouts,
Approaches to CSS Layout, Responsive Design, CSS
Frameworks.
• Module – 3
JavaScript: Client-Side Scripting, What is JavaScript and
What can it do?, JavaScript Design Principles, Where
does JavaScript Go?, Syntax, JavaScript Objects, The
Document Object Model (DOM), JavaScript Events,
Forms, Introduction to Server-Side Development with
PHP, What is Server-Side Development, A Web Server’s
Responsibilities, Quick Tour of PHP, Program Control,
Functions
• Module – 4
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, Error Handling and
Validation, What are Errors and Exceptions?, PHP Error Reporting,
PHP Error and Exception Handling
• Module – 5
Managing State, The Problem of State in Web Applications, Passing
Information via Query Strings, Passing Information via the URL Path,
Cookies, Serialization, Session State, HTML5 Web Storage, Caching,
Advanced JavaScript and jQuery, JavaScript Pseudo-Classes, jQuery
Foundations, AJAX, Asynchronous File Transmission, Animation,
Backbone MVC Frameworks, XML Processing and Web Services,
XML Processing, JSON, Overview of Web Services.
Course Outcomes
• Adapt HTML and CSS syntax and semantics to build
web pages.
• Construct and visually format tables and forms using
HTML and CSS
• Develop Client-Side Scripts using JavaScript and Server-
Side Scripts using PHP to generate and display the
contents dynamically.
• Infer object oriented programming using JavaScript and
Server side programs using PHP.
• Inspect JavaScript frameworks like jQuery and
Backbone which facilitates developer to focus on core
features.
MODULE 1
What the Internet is?
http://www.funwebdev.com/index.php?page=17#article
?username=john&password=abcdefg
Values
Delimiters
INTRODUCTION TO HTML
HTML
• HTML is defined as a markup language.
• A markup language is simply a way of annotating a
document in such a way to make the annotations
distinct from the text being annotated.
• The term comes from the days of print, when editors
would write instructions on manuscript pages that
might be revision instructions to the author or copy
editor.
• markup is a way to indicate information about the
content
• This “information about content” in HTML is
implemented via tags (aka elements).
• The markup in the previous slide consists of the red
text and the various circles and arrows on the one
page, and the little yellow sticky notes on the other
• HTML does the same thing but uses textual tags
What is the W3C?
• The W3C is the main standards organization for the
World Wide Web.
• To promotes compatibility the W3C produces
recommendations (also called specifications).
HTML: HyperText Markup Language
• HTML documents are simply text documents with
a specific form
– Documents comprised of content and markup tags
– Content: actual information being conveyed
– The markup tags tell the Web browser how to display
the page
– An HTML file must have an htm or html file extension
– An HTML file can be created using a simple text editor
History of HTML
1999 HTML 4.01 XHTML 2.0 had even stricter standards than 1.0,
rejecting web pages that did not comply. It fell
2000 XHTML 1.0 out of favor gradually and was abandoned
completely in 2009.
2002
-2009 XHTML 2.0
HTML5 is much more tolerant and can handle
markup from all the prior versions.
<html>
<head>
<title>Title of page</title>
</head>
<body>
This is my first homepage. <b>This text is bold</b>
</body>
</html>
<!DOCTYPE html>
Just 15 characters!
The DOCTYPE tells the browser which type and version of document to expect. This
should be the last time the DOCTYPE is ever changed. From now on, all future
versions of HTML will use this same simplified declaration.
The <html> Element
This is what the <html> element looked like in XHTML:
<html lang="en">
The lang attribute in the <html> element declares which language the page content
is in. Though not strictly required, it should always be specified, as it can assist
search engines and screen readers.
Each of the world’s major languages has a two-character code, e.g. Spanish = "es", French =
"fr", German = "de", Chinese = "zh", Arabic = "ar".
The <head> Section
<head>
<meta charset="utf-8">
<title>My First HTML5 Page</title>
</head>
Notice the simplified character set declaration, the shorter CSS stylesheet link text,
and the removal of the trailing slashes for these two lines.
Basic HTML5 Web Page
Putting the prior sections together, and now adding the <body> section and closing
tags, we have our first complete web page in HTML5:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My First HTML5 Page</title>
</head>
<body>
<p>HTML5 is fun!</p>
</body>
</html>
Even though we used HTML5, the page looks exactly the same in a web browser as it
would in XHTML. Without looking at the source code, web visitors will not know
which version of HTML the page was created with.
A QUICK TOUR OF HTML ELEMENTS
Basic Text Markup
Text is normally placed in paragraph elements
1. Paragraph Elements
The <p> tag breaks the current line and inserts a blank line
- the new line gets the beginning of the content of the paragraph - The
browser puts as many words of the paragraph’s content as will fit in each
line.
- The closing paragraph tag is required by XHTML
<!-- greet.hmtl A trivial document -->
<html>
<head> <title> Our first document </title>
</head>
<body> <p>
Greetings from your Webmaster!
</p> </body>
</html>
Basic Text Markup( conti….)
2. Line breaks
– The effect of the <br /> tag is the same as that of <p>, except for the blank
line
• No closing tag!
• Example of paragraphs and line breaks
On the plains of hesitation <p> bleach the
bones of countless millions </p> <br />
who, at the dawn of victory <br /> sat down
to wait, and waiting, died.
4. Blockquotes
-Content of <blockquote>
-To set a block of text off from the normal flow and appearance of text
-Browsers often indent, and sometimes italicize
Basic Text Markup( conti….)
6. Font Styles and Sizes (can be nested)
– Boldface - <b>
– Italics - <i>
– Larger - <big>
– Smaller - <small>
– Monospace - <code>
– Emphasis(italics)- <em>
– Strong (boldface)-<strong>
- <code>,<em>,<strong>- are called as content based style tags.
– Subscript - <sub>
– Superscript - <sup>
Basic Text Markup( conti….)
The <big> sleet <big> in <big> <i> Crete
</i><br /> lies </big> completely </big>
in </big> the street
- All of this font size and font style stuff can be done with style sheets, but these tags are
not yet deprecated
Basic Text Markup( conti….)
7. Character Entities:
entities are the names for the character by the browser. An entity in a
document is replaced by its associated character by the browser.
Basic Text Markup( conti….)
8. Horizontal rules
– <hr /> draws a line across the display, after a line break
Label (image)
Types of Links
You can use the anchor element to create a wide range of
links:
• Links to external sites (or to individual resources such
as images or movies on an external site).
• Links to other pages or resources within the current
site.
• Links to other places within the current page.
• Links to particular locations on another page.
• Links that are instructions to the browser to start the
user’s email program.
• Links that are instructions to the browser to execute a
Javascript function.
Different link destinations
Link to external site
<a href="index.html">Home</a>
Link to email
<a href="mailto://[email protected]">Someone</a>
Text in alt attribute provides a brief Specifies the width and height of
description of image’s content for users who image in pixels.
are unable to see it.
Lists
HTML provides three types of lists
<header>
<hgroup>
<h1>Chapter Two: HTML 1</h1>
<h2>An Introduction</h2>
</hgroup>
</header>
<article>
<hgroup>
<h2>HTML5 Semantic Structure Elements </h2>
<h3>Overview</h3>
</hgroup>
</article>
Navigation
<nav>
- The CSS1 cascading style sheet specification was developed in 1996 by W3C;
followed by CSS2 in 1998
- One of the most important capabilities of style sheets is that they allow you to
impose a standard style on a whole document, or even a whole collection of
documents
•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
markup.
</body>
</html>
2. Grouping Selectors
• If you have elements with the same style definitions, You can select
a group of elements by separating the different element names
with commas
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p{
text-align: center;
color: red;
}
The above style can be written using group selector as:
h1, h2, p {
text-align: center;
color: red;
}
3. Class Selectors
• A class selector allows you to simultaneously
target different HTML elements regardless of
their position in the document tree.
• To select elements with a specific class, write a
period (.) character, followed by the name of
the class.
• In the example below, all HTML elements with
class="center" will be red and center-aligned
In the example below, all HTML elements with class="center" will
be red and center-aligned
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">"WELCOME"</h1>
<p class="center">Welcome to programming the web.</p>
<p> Introduction to HTML </p>
</body>
</html>
4. Id Selectors
• 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.
The style rule below will be applied to the HTML
element with id="para1":
<!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
}
</style>
</head>
<body>
</body>
</html>
• Id selectors should only be used when referencing a
single HTML element since an id attribute can only
be assigned to a single HTML element.
• Class selectors should be used when (potentially)
referencing several related elements.
5. Attribute selectors
• Selects html elements either by presence of element attribute or by value of an attribute
<head>...... 1. [title]
<style> 2. a[title=”posts from this country”]
[title] { 3. [title~=”countries”]
cursor: help; 4. a[href^=”mailto”]
padding-bottom: 3px; 5. Img[src*=”flag”]
..... 6. a[href$=”.pdf]
}
</style> </head>
<body>
<div>
<img src=“.....” title=“flags” />
<h2><a href=“....” title=“post from “>country </a> </h2>
<p>this is our country flag</p>
<div>
<image src=“.....” title=“....” />
<image src=“.....” title=“....” />
<image src=“.....” title=“....” />
</div> </div> </body>
6. Pseudo element and pseudo –class selector
• A pseudo element selector is a away to select something that does not exist
explicitly as an element in the HTML document tree
<style>
a:link { :checked
text-decoration: underline; :first-child
color: blue; :first-letter
} :first-line
a:visited { other common elements
text-decoration: underline;
color:purple;
}
a:hover {
text-decoration: none;
font –weight: bold;
}
a: active {
background-color: yellow;
}
</style>
7. Contextual selector
Syntax:
div p {....} //(p element of div element)
#main div p:first-child {...} //(first p element of div element within id=main)
1. Descendant div p
2. Child div>h2
3. Adjacent sibling h3+p
4. General sibling h3~p
THE CASCADE: HOW STYLES INTERACT
• Why Conflict Happens
Because
there are three different types of style sheets
(author created, user-defined, and the default
browser style sheet),
author-created stylesheets can define multiple
rules for the same HTML element,
• CSS has a system to help the browser determine
how to display elements when different style
rules conflict.
Cascade
• 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.
• 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 elements.
Cascade Principles
• CSS uses the following cascade principles to
help it deal with conflicts:
inheritance,
specificity,
location
Inheritance
• 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.
div {
font-weight: bold; //inherited
margin: 50px; //not inherited
border: 1pt solid green;
}
P{
border: inherit;
margin: inherit;
}
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.
• The more specific the selector, the more it
takes precedence (i.e., overrides the previous
definition).
body {
font-weight: bold;
color: red;
} ex: <body>
div { <p>.....</p>
font-weight: normal; <div>
color: magenta; <p>.....
} <p>...
P{ </div>
color:green; <div>.....</div>
}
.last {
Color: blue;
}
Specificity algorithm
Element selector
Descendant selector
Class and attribute selector overrides
Id selector
Id +additional selectors
Inline style attributes
Location
• When inheritance and specificity cannot
determine the precedence of style, location is
used
• Principle of location is that, when rules have
the same speficity, then latest are given more
weight
<head>
<link rel=“stylesheet” href=“stylesA.css” />
<link rel=“stylesheet” href=“stylesww.css” />
<style>
#example {
color: orange;
color: meganta;
}
</style>
</head>
<body>
<p id=“example” style=“color:red;”>
Sample text </p>
</body>
THE BOX MODEL
• In CSS, all HTML elements exist within an element
box.
• It is absolutely essential that you familiarize yourself
with the terminology and relationship of the CSS
properties within the element box.
• Content - The content of the box, where text and
images appear
• Padding - Clears an area around the content. The
padding is transparent
• Border - A border that goes around the padding and
content
• Margin - Clears an area outside the border. The
margin is transparent
background
• background :- for multiple multiple values in one
property
• background-attachment :- fixed, scroll
• background-color :-
• background-image :- multiple image in css3
• background-position :-bottom, center, left, right
• background-size :- in css3 also for image
• background-repeat :- repeat, repeat-x, repeat-y,
no-repeat
border
• border :- for multiple multiple values in one
property
• border -style :- solid, dotted, dashed, double etc
• border -width :- thin, medium etc or in units.
• border -color :- color units
• border -radius :-radius of rounded corner
• border -image :- url of image to use border
1. p { 2. p { 3. p {
border: solid 1pt red; border: solid 1pt red; border: solid 1pt red;
margin:0; margin:30px; margin:30px;
padding:0; padding:0; padding:30px;
} } }
Ex:
<div>
<p>......</p> div {
<p>.....</p> border: dotted 1pt green;
</div> padding:0;
<div> margin: 90px 20px;
<p>....</p> }
<p>......</p> p{
</div> border: solid 1pt red;
padding:0;
margin: 90px 20px;
}
• Calculate true element width and height for the following:
div {
box-sizing: content-box;
width:200px;
height:100px;
padding:5px;
margin: 10px;
border: dotted 2pt green;
}
</div>
<p>The CSS box model is essentially a box that wraps around every HTML element. It consists of:
borders, padding, margins, and the actual content.</p>
<div>This text is the actual content of the box. We have added a 25px padding, 25px margin and a 25px
green border.
</body>
</html>
TEXT STYLING
• Text Properties
• CSS provides two types of properties that affect text.
•font properties that affect the font and its appearance.
•paragraph properties that affect the text in a similar
way no matter which font is being used.
• font
• font-family
• font-size :-1em=1*16pixel
• font-style
• font-variant
• font-weight
• Specifying the Font-Family