Fundamentals of Web Development With: Html5, Css3, Javascript
Fundamentals of Web Development With: Html5, Css3, Javascript
Fundamentals of Web Development With: Html5, Css3, Javascript
JavaScript
• Interactivity with User
• Dynamic Updates in a Web Page
CSS
• Cascading Style Sheets
• Presentation/Styling
t
Hypertext - Origins
HyperText
• Text with references (hyperlinks) to other text
“Hyper” - meaning
• Greek Origin: “over”, “beyond”
First Idea
• Vannevar Bush, USA, in 1945
A Simple HTML5 Page
t
Hosting a Web Site
A Web Site
• Serves one or more HTML Pages
Default Page: index.html, index.php
Served / Hosted by a Web Server
• HTTP Web Server
https, apache2, Ngnix - Internet Information Server (Microsoft’s)
• Web Application Server
Visual Studio Code (Microsoft) , Sublime Text, Atom
Technologies
• HTML, HTTP, TCP/IP Protocols
• Operating Systems: Linux, Windows, MacOS
HTML Page
HTML (Web) Page / Document
• User Interface for the Web (site or application)
• A plain text file – human readable
• Transported on HTTP - HyperText Transfer Protocol
Page Types
• Static – ready-made pages with fixed page content
File Extension: .html, .htm
• Dynamic – generated on the fly with varying page content
Generated on the Web Server
Interspersed with JavaScript, PHP, JSP, ASP
File Extensions: .js, .php, .jsp, .asp, .aspx
CSS - Introduction
Cascading Style Sheet
• Describes the look and formatting of a page
• Used for Changing Presentation and Styling
• Can apply to a mark-up language
HTML, XHTML, XML, SVG
Separates Content from Presentation
Properties (Attributes) Styled
• Layout, Font (Typography), Color, Background
• Box Properties: Border, Margin, Padding
• Lists, Tables
.
CSS Syntax (Contd./-)
Style Selector
• The HTML elements to which the Style rule should be applied
• It is a match expression
• Specified as:
Element’s tag name
h1, p, label - case insensitive
Value of Element’s attribute
id, class - Case Sensitive
Element’s placement in the Document tree
Child element is nested within Parent
A Sibling element is at the same nesting level
CSS Syntax (Contd./-)
CSS Declaration Block
• List of Declarations
• Enclosed in curly braces { . . . }
• Declaration
property : value(s) ;
• property and value(s) are pre-defined
• Property name is unique
• Property value – Specified in multiple formats
keywords (words) or mnemonics (in combination with some symbols like: #, /)
numerical, hexadecimal, or a combination
some values may have units of measure
New CSS3 Selectors
New CSS3 Structural Pseudo-Class Selectors
• E:first-of-type – Selects the first element of type E for its parent
li:first-of-type { color: red; }
Transformation
• Change of position, shape and size of an element
CSS3 Transforms
• 2-D: Two Dimensions
• 3-D: Three Dimensions (not covered in this course)
Transform Operations
• move, scale, spin, stretch and turn elements
Slide
16
CSS3 – 2D Transforms (Contd./-)
Specified with transform attribute
• Translation – Movement along X-axis and Y-axis
transform: translate( 50px, 100px );
• Rotation – in clock-wise direction
transform: rotate( 5deg );
• Scaling – increase/decrease size along width and height
transform: scale( 2, 2 );
• Skewing – tilting (turning) in X-axis and Y-axis directions
transform: skew( 10deg, 5deg);
Slide
17
CSS3 Transitions
Changing from one style to another (on an event)
CSS property on which the transition effect has to take place
Time Duration over which transition has to take place (smoothly)
Specified in seconds (s) or milliseconds (ms)
p { width: 100px; }
p:hover { width: 200px; transition: width 2s; }
Transition starts on events
Events: hover, active, checked, focus, enabled, disabled
@media queries, and JavaScript
Specify multiple transitions sets with a comma
p { width: 200px; height: 100px; }
p:hover {
width: 400px; height: 200px;
transition: width 2s, height 5s; }
Slide
18
JavaScript – An Introduction
Mocha, later renamed as LiveScript - Developed by Netscape
Based on ECMAScript 5.1 (Ver. 6.0 is finalized in mid 2015)
LiveScript JavaScript (due to Java popularity)
Scripting Language for Web Browsers
• Dynamically Typed
• Interpreted by JavaScript Engine
Can not Do (for Security Reasons)
• Unlimited reading/writing of files from client machine’s file system
• Writing to the files on the Server
• Can not close a window that was not opened by it
• Can not read from a web page served by another web server
Microsoft’s version - JScript Slide
19
Document Object Model (DOM) (Contd./-)
Structure and Style of a Page, Access / Update Content
DOM + JavaScript = Dynamic HTML (on client-side)
What JavaScript can do with DOM?
Change an HTML Element
Change an attribute of an HTML Element
Change the CSS style of an HTML Element
Remove an existing HTML element or its attributes
Add new a HTML Element or a new attribute to an Element
React to an event associated with an HTML Element
Create a new event listener and associate with an HTML Element
Slide
20
HTML DOM Methods
DOM Methods – Finding HTML Elements
• getElementById() Method
Gets the HTML Element with specified ID
• getElementsByClassName() Method
Gets the HTML Elements with specified class name
document.getElementsByClassName("middlePara")[0].innerHTML = "Welcome
to My Website!";
document.getElementsByClassName("middlePara")[1].innerHTML = "This is
HTML5, CSS3 and JavaScript presentation!";
• getElementsByTagName() method
Gets the HTML Elements with specified element tag
document.getElementsByTagName("p")[0].innerHTML = "Welcome to
My Website!";
document.getElementsByTagName("p")[1].innerHTML = "This is HTML5,
CSS3 and JavaScript presentation!";
Slide
21
jQuery - Introduction
jQuery Core – a Cross-Platform JavaScript Library
• Simplifies client-side JavaScript scripting for a web page
• It is FREE and Open Source
• Used by about 6,000 most visited websites
• It uses the familiar HTML DOM model
Latest Versions
• Version 1.11.3 - has support for IE 6/7/8
• Version 2.1.4 - has NO support for IE 6/7/8
• Development Version
For use during development of the website
• Minified Version
For use in production (live / online) use of website
Slide
22
jQuery - Introduction
Why use jQuery?
• JavaScript Framework
• Separates HTML and JavaScript in a web page
• Eliminates cross-browser incompatibilities
• Simple/Short, Clean and Easy to read, write and understand
What jQuery can do?
• Can Select Elements
Has Selectors are similar to CSS Selectors
• Can Manipulate the Selected Elements
• Can Modify the Style of the Selected Elements
• Supports Events, Effects and Animations
• Supports JSON Parsing and Ajax (Asynchronous JavaScript + XML) Slide
23
jQuery Basics
Download the latest version
• From jquery.com website
Reference it in HTML file
• Host it on your Web Server and Use it with <script> tag
<script src="jquery-2.1.3.js"></script>
• Point to a Public Web Server and Use it with <script> tag
Google CDN Server (recommended) CDN – Content Delivery Network
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
Microsoft CDN Server
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js">
</script>
MaxCDN CDN Server (moved from MediaTemple, before that Amazon)
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
• Do not put the jQuery code in the <script> tag that loads jQuery library
Advanced Web Programming Topics
HTML Canvas, WebGL, SVG