0% found this document useful (0 votes)
499 views284 pages

Awp

AWP technical

Uploaded by

Archi Jariwala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
499 views284 pages

Awp

AWP technical

Uploaded by

Archi Jariwala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 284
SUBJECT CODE : 3161611 As per New Syllabus of GUJARAT TECHNOLOGICAL UNIVERSITY ‘Semester - VI (IT) Professional Elective - II] ADVANCED WEB PROGRAMMING Anuradha A. Puntambekar ME. (Computer) Formerly Assisiant Professor in PE.S. Modern College of Engineering, Pune => TECHNICAL PUBLICATIONS ‘An Up-Thrust for Knowledge Ew ADVANCED WEB PROGRAMMING Subject Code : 3161611 Semester - VI (Information Technology) Profesional Elective - II © Copyright with Author All publishing rights (printed and ebook version) reserved with Technical Publications. No port of this book should be reproduced in any form, Electronic, Mechanical, Photocopy or ony information storage and retrieval system without prior permission in writing, from Technical Publications, Pune. Published by : = 18) Amit Residency, Office No.1, 412, Shaniwar Peth, TECHNICAL) ore vess us month, 91 ore2eesess7 Sesh Kahle ans cgrenstatciaerso Printer : Yosial Pintes & Binders S.No. 10/1, ‘Ghule Industil Estate, Nanded Village Road, Tal. - Havel, Dist. - Pune - 411041 ISBN 978-93-90770-24.3 7893900770243 9789390770243 [1] @ PREFACE The importance of Advanced Web Programming is well known in various engineering fields. Overwhelming response to my books on various subjects inspired me to write this book. The book is structured to cover the key aspects of the subject Advanced Web Programming. The book uses plain, lucid language to explain fundamentals of this subject. The book provides logical method of explaining various complicated concepts and stepwise methods to explain the important topics. Each chapter is well supported with necessary illustrations, practical examples and solved problems. All the chapters in the book are arranged in a proper sequence that permits each topic to build upon earlier studies. All care has been taken to make students comfortable in understanding the basic concepts of the subject. Representative questions have been added at the end of each section to help the students in picking important points from that section. The book not only covers the entire scope of the subject but explains the philosophy of the subject. This makes the understanding of this subject more clear and makes it more interesting. The book will be very useful not only to the students but also to the subject teachers. The students have to omit nothing and possibly have to cover nothing more. I wish to express my profound thanks to all those who helped in making this book a reality. Much needed moral support and encouragement is provided on numerous occasions by my whole family. I wish to thank the Publisher and the entire team of Technical Publications who have taken immense pain to get this book in time with quality printing. Any suggestion for the improvement of the book will be acknowledged and well appreciated. Author A.A. Puntambekar Dedicated to God, SYLLABUS Advanced Web Programming - 3161611 Credits Examination Marks Total Marks c ‘Theory Marks Practical Marks ESE (E) PA(M) ESE(V) PA() 4 70 30 30 20 150 Refreshing Java Script and CSS CSS syntax, benefits, Responsive design, Bootstrap introduction, Java script syntax, Java script inbuilt objects, Error handling and event handling, DOM, Asynchronous Programming. (Chapter - 1) Introduction to Angular JS Basics and Syntax of Angular JS, Features, Advantages, Application Structure, Basics of routes and navigation, MVC with Angular JS, Services. (Chapter -2) Angular JS in Det: Modules, Directives, Routes, Angular JS Forms and Validations, Data binding, Creating single page website using ‘Angular JS. (Chapter -3) Introduction to Node JS ‘Setup Node JS Environment, Package Manager, Features, Console Object, Concept of Callbacks. (Chapter - 4) Node JS in details Events and Event Loop, timers, Error Handling, Buffers, Streams, Work with File System, Networking with Node (ICP, UDP and HTTP clients and servers), Web Module, Debugging, Node JS REST API, Sessions and Cookies, Design pattems, caching, scalability. (Chapter -5) Database Programming with Node JS and MongoDB Basics of MongoDB, Data types, Connect Node JS with MongoDB, Operations on data (Insert, Find, Query, Sort, Delete, Update) using Node JS. (Chapter - 6) @ TABLE OF CONTENTS Chapter-1 Refreshing Java Script and CSS (1-1) to (1-114) Part I : CSS and Bootstrap 1.1 Introduction to CSS... 1.1.1 Benefits of CSS. 1.2 CSS Syntax and Structure. 1.3 Location of Styles. 1.3.1 Inline Style Sheet 1.3.2 Document Level Style Sheet 1.3.3 External Stylesheet 1.4 Selectors. 1.4.1 Simple Selector Form. 1.4.4 1d Selectors 1.4.5 Universal Selectors 1.4.6 Attribute Selector 1.4.7 Contextual Selector .. 1.5 Background 1.6 Color and Color Properties 1.6.1 Color Groups.. 1.6.2 Color Properties. 1.7 Manipulating Texts and Fonts .. 1.7.1 Font Familie 1.7.2 Font Sizes. 1.7.3 Font Variants .. 1.7.4 Font Styles .. © 1.7.5 Font Weights 1.7.6 Font Shorthands 1.7.7 Text Decoration 1.7.8 Alignment of Text . 1.8 Lists . 1.9 Responsive Design 1.9.1 Setting Viewports . 1.9.2 Media Queries 1.10 Bootstrap Introduction 1.10.1 Grid Syster 1.10.2 Typography 1.11 Java Script Syntax. 1.12 Java Script Inbuilt Objects. 1.12.1 Math Objects. 1.12.2 Number Objects. 1.12.3 Date Objects 1.12.4 Boolean Objects. 1.125 String Objects . 1.12.6 Object Creation and Modification .. 1.13 DOM.. 1.13.1 Definition of DOM... 1.13.2 DOM Tree 1.13.3 Using DOM Methods 1.1.3.1 Accessing Elements using DOM. wi) 1.13.3.2 Modifying Elements using DOM. 1.14 Event Handling. 1.14.1 Handling Events from the Body Elements... 1.15 Error Handling. 1.16 Validators. 1.17 Asynchronous Programming 1-105 1.17.1 Introduction to AJAX. 1-105 1.17.2 Architecture... 1-105 1.17.3 XMLHttpRequest Object 1-107 Chapter-2 Introduction to Angular JS (2 - 1) to (2 - 18) 2.1 Basics of Angular JS.. 2-2 2.2 Features . 2-2 2.3 Advantages and Disadvantages ... 2-2 2.4 Application Structure. 2-3 2.5 MVC with Angular J: 2-5 2.6 Basics of Routes and Navigation.. 2-6 2.7 Expression... ace 2.8 Controller... 2-9 2.9 Scope... i 2.10 Services -16 Chapter-3 Angular JS in Details @B- 1) to (3-26) 3.1 Directives ... 3-2 3.2 Modules .. 3.3 Routes 3.4 Angular JS Forms and Validations 3.5 Data Binding 3.6 Creating Single Page Website using Angular JS... (wi Chapter-4 Introduction to Node JS (4-1) to (4-12) 4.1 Setup Node JS Environment 4-2 4.2 Package Manager. 4-4 4.3 Features .. 4-7 4.4 Console Object.. 4-8 4.5 Concept of Callback: -10 Chapter-5 Node JS in Details (8 - 1) to (5 - 66) 5.1 Events and Event Loop. 5-2 5.1.1 Introduction to Events. 5-2 5.1.2 Concept of Event Loop. 5-4 5.2 Timers 5-6 5.3 Error Handling 5.4 Buffers, Streams, Work with File System... 5.4.1 What is Buffer ?.. 5.4.2 Concept of Stream. 5.4.3 File System 5.5 Networking with Node. 5.6 Web Module 5.7 Debugging... 5.8 Express in NodelS 5.9 Node JS REST API 5.10 Sessions and Cookies 5.10.1 Sessions .. 5.10.2 Cookie. 5.11 Design Patterns. 5.12 Caching and Scalability (wit) Chapter-6 Database Programming with Node JS and MongoDB (6 - 1) to (6 - 34) 6.1 Basics of MongoDB... 6.2 Data Types 6.3 MongoDB Installatior 6.4 Database Commands. 6.5 Connect Node JS with MongoDB... 6.6 Operations on Data using Node JS.. Solved Model Question Paper (M- 1) to (M- 2) Notes 9 Refreshing Java Script and CSS ‘Syllabus CSS syntax, benefits, Responsive design, Bootstrap introduction, Java script syntax, Java script inbuilt objects, Error handling and event handling, DOM, Asynchronous Programming. Contents Part! : CSS and Bootstrap 1.1 Introduction to CSS 1.2 CSS Syntax and Structure 1.3 Location of Styles 1.4 Selectors 1.5 Background 1.6 Color and Color Properties 1.7 Manipulating Texts and Fonts 1.8 Lists 1.9 Responsive Design 1.10 Bootstrap Introduction Part Il : JavaScript 1.11 Java Script Syntax 1.12 Java Script Inbuilt Objects 1.13 DOM 1.14 Event Handling 1.15 Error Handling 1.16 Validators 1.17 Asynchronous Programming aa Advanced Web Programming 2 Refreshing Java Script and CSS Part I : CSS and Bootstrap EE introduction to css © The CSS stands for Cascading Style Sheet. ‘© The Cascading Style Sheet is a markup language used in the web document for presentation purpose. © The primary intension of CSS was to separate out the web content from the web presentation. * Various elements such as text, font and color are used in CSS for presentation purpose. Thus CSS specification can be applied to bring the styles in the web document. ERE] Benefits of css Following are important benefits of CSS : () Improved Control Over Formatting : The web page developer (called as web author) have better control over formatting of web contents. (2) Improved Site Maintainability : It becomes easy to maintain the site because the formatting is centralized into one CSS file. (3) Improved Accessibility : The CSS driven sites are more accessible and give the user significantly enriched experience of accessibility of the web page. (4) Improved Download Speed : As all the formatting is centralized into one CSS file, all presentation will be quicker to download. () 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. x What is CSS? Enlist the benefits of CSS. EEcss syntax and Structure The style specification is specified differently for each different level. For instance : * For inline cascading style sheets the style appears in side the tag for defining the value, ‘

TECHNIGAL PUBLIGATIONS® - An up thst for knowacige Advanced Web Programming 1-3 Refreshing Java Script and CSS * For the document cascading style sheet the style specification appear as the content ofa style element within the header of a document. Property Value Selector The type attribute tells the browser that what it is reading is text which is affected by the Cascading Style Sheet. The type specification is necessary because there is one more specification used in JavaScript. * The External style sheet makes use of style specification in the same manner as in document cascading style sheet. The most commonly used CSS properties are enlisted in the following table — Property Type Property Fonts font font-family font-size font-style font-weight @font-face Text letter-spacing line-height text-align textdecoration textindent Color and background background background-color background-image background-position background-repeat color TECHNIGAL PUBLIGATIONS® - An up thst for knowaciga Advanced Web Programming 1-4 Refreshing Java Script and CSS Borders border border-width border-style border-top border-top-color border-top-width Spacing, padding padding-bottom, padding-left, padding- right, padding-top margin margin-bottom, margin-left, margin- right, margin-top height maxheight max-width min-height min-width width Layout bottom, left, right, top clear display float overflow position visibility z-index TECHNIGAL PUBLIGATIONS® - An up thst for knownciga Advanced Web Programming 1-5 Refreshing Java Script and CSS Lists liststyle liststyle-image liststyle-type EE) Location of Styles There are three levels of cascading style sheets - Inline style sheet ‘* Document level style sheet ‘© External level style sheet EEE] inline Style Sheet © The inline cascading style sheet is a kind of style sheet in which the styles can be applied to HTML tags. This tag can be applied using following rule - Tag { property: value } © Forexample : ‘

Here for the tag p two properties are used such as font-family and color and those are associated with the values such as Arial and red respectively. ‘* Note that if we want to use more than one property then we have to use separator such as semicolon. In the following HTML document we have used cascading style sheet- HTML Document [InlineStyle.htmi] < Inline Cascading Style Sheet

This is simple text

This text is colored.

TECHNICAL PUBLIGATIONS® - An up thrust for knowaciga Advanced Web Programming 1-6 Refreshing Java Script and CSS Script Explanation 1) In this document, in the body section the style sheets are created. 2) _In this section first of all we have displayed a simple sentence This is simple text. There is no style for this sentence. 3) In the next line, we have applied style in which font-size is set to the size of 30 point and font-family is set by the font name “Script” . 4) Then colored text will be displayed by color:#ff0000". The first two digits ff denote the red color, there is no green and blue color as the values next to ff are 00, Hence the text will be displayed in red. This can be very well illustrated in output. Output Brine Cnacading Sipe Shnet > Window internet Fxpisrer Dee ovr en tempraininesntentes —~] |< [P| Bl cet more nac-one = (@ trline Cascading Ste Sheet te ~ Tis toad i diffrent This text is colored. EEE] Document Level Style Sheet ‘* This type style sheet appears only in the head section and in the body section newly defined Selector tags are used with the actual contents. * For example : In the following HTML script we have defined hi, h2, h3 and p selectors. For each of these selectors different property and values are set. Such setting will help us to represent our web page in some decorative form. ‘* The most important thing while writing document level style sheet is that we should mention the style type="text/css” in the head section. By this the browser will come to know that the program is making use of cascading style sheet. TECHNIGAL PUBLIGATIONS® - An up thst for knowaciga Advanced Web Programming 1-7 HTML Document [DocLevelCSS.html] Document Level style sheet
This page is created using Document Level Style Sheet

This line is aligned left and red colored.

Refreshing Java Script and CSS ‘The embedded style sheet is the most commonly used style sheet. This paragraph is written in Verdana font with font size of 14.

‘This is a blue colored line. TECHNICAL PUBLIGATIONS® - An up thst for knowaciga ‘Advanced Web Programming 1-8 Refreshing Java Script and CSS This page is created using Document Level Style Sheet This line is aligned left and red colored paragraph is written in Vergana font with tone sige oF Script Explanation 1) _ In above program, we have defined all the selectors in the head sections only. And these HTML elements are then used along with the web page contents. 2) The setting defined in the selectors will affect the web page contents. For example we have defined the selector h2 as. =a oa ‘Selector { t-family:Arial; color:red; left:20px } ‘Value and then in the body section we have written - ‘

This line is aligned left and red colored.

3) Now as h2 defines font to be “Arial” with color as “red” having left alignment of 20 pixels, the sentence “This line is aligned left and red colored.” will be displayed in Arial font, which is red colored and aligned from left by 20 pixels. Surely we can see this effect on our web browser. EEE] External Stylesheet ‘* Sometimes we need to apply particular style to more than one web documents in such cases external style sheets can be used. TECHNIGAL PUBLIGATIONS® - An up thst for knowiacige Advanced Web Programming 1-9 Refreshing Java Script and CSS ‘© The central idea in this type of style sheet is that the desired style is stored in one .ess file. And the name of that file has to be mentioned in our web pages. ‘Then the styles defined in .css file will be applied to all these web pages. © Here is a sample program in which external style sheet is used. Step 1: Create an HTML document HTML Document{ExtCSS.htm] <
This page is created using External Style Shest

‘This line is aligned left and red colored. <2>

‘The External style sheet is the compact representation of Cascading Style Sheets. ‘This paragraph is written in Monotype Corsiva font with font size of 14.

‘This is a blue colored line. Step 2: Create a css file which contains the styles that can be applied to different HTML elements present in the above HTML document. The cascading style sheet ex1.css can be _ Output nt Fn eee ee { dads mal oo font-family:Arial reenter + 2 ‘This page is created using External Style Sheet { {his ine i aligned tet und red colored. Sane a esas la seme treatin Cin Si hoe para color:red; Tian n wemye oat 1eft:20px ‘This isa biue colored tne, + 2s. cog saat TECHNIGAL PUBLIGATIONS® - An up thst for knowaciga Advanced Web Programming 1-10 Refreshing Java Script and CSS 4 font-family:arial; color:blue; + P { font-size:14pt; font-family:Monotype Corsiva + Script Explanation When we want to link the external style sheet then we have to use tag which is to be written in the head section. * link tells the browser some file must be linked to the page. © rel= tylesheet tells the browser that this linked thing a style sheet. * href=" "denotes the path name of style sheet file. type="text/css" tells the browser that what it is reading is text which is affected by the cascading style sheet. Hii selectors Ed simple Selector Form ‘© The simple selector form is a single element to which the property and value is applied. ‘* We can also apply property and value to group of elements. ‘* Following is an illustration for simple selector form. HTML Document{SimpleSel.htm!] Simple Selector Form

India is My Country ‘All the Indians are my brothers and sisters

I love my country
Geer Ae Coad BT me Per sey India is My Country All the Indians are my 6rothers and sisters + J love my country Similarly the style can also be applied to the elements at specific positions. For example : body b p {font-size:18pt;} Note that there are more than one element to which the style is applied and these elements are separated by the white spaces. EEE class Selectors ‘© Using class selector we can assign different styles to the same element. ‘* These different styles appear on different occurrences of that element. TECHNIGAL PUBLIGATIONS® - An up thst for knowiaciga ‘Advanced Web Programming 1-12 For example HTML Document[ClassSel.html] Class Selector Form India is My Country Refreshing Java Script and CSS ‘ All the Indians are my brothers and sisters

I love my country

Output Bose fe) DexHM fomplenicieseitem ~[42]][P Tagen coe P ~] GO ‘Be Fveries | op ie) Suggesed stes~ (2) Get Mere Ate one © | Clee Slector Form Pe DT Be Pager seteye India is My Country {All the Indians-are my brothers and sisters I love my country ME Computer| Prtected Mode OFF TECHNIGAL PUBLIGATIONS® - An up thst for knownciga ‘Advanced Web Programming 5-13 Following Nodejs script shows how to write data to the string, writeStreamExamplejs var fs = require(‘fs"); var str =" This line is written to myfile’; var ws = fs.createWriteStream(sample.txt); ‘ws. write(str, tf}; ‘ws.end(); ‘console.log("The data is written to the file. ‘Node JS in Details {BH Command Prompt - a D:\NodeJSExamples>node writeStreamExample. js |The data is written to the file... D:\NodeJSExamples>type sample.txt This line is written to myfile D: \NodeISExanples>, The above code is simply modified to handle the error event as follows - var fs = require(‘ts"); var str =" This line is written to myfile var ws = fs.createWriteStream(‘sample.txt’); ws.write(str,'utf8'); ws.end(); console.log("The data is written to the file..."); ‘ws.on(error’function(err) { ‘console.log(err.stack); Mi Read Operation For reading from the stream we use createReadStream. Then using the data event the data can be read in chunks. TECHNICAL PUBLICATIONS - An up trust for knowiadge Advanced Web Programming Refreshing Java Script and CSS POR 8 EE] Generic Selectors ‘© We define the class in generalised form. ‘* Inthe sense, that particular class can be applied to any tag. ‘© Here is the HTML document which makes use of such generic selector. HTML Document [ClassSel1.html] Generic Class Selector Form<title> <style type="text/css"> ‘RedText { font-family:Monotype Corsiva; color:red; } </style> </head> <body> ‘<center> <h1> Tongue Twister</h1> </center> ‘<h2 class="RedText"> ‘Sho sells sea shells on the sea shore, <a> ‘<h3 class="RedText"> ‘The shells she sells are sea shells, I'm sure. </n3> <hf class="RedText"> And if she sells sea shells on the sea shore, <a> TECHNIGAL PUBLIGATIONS® - An up thrust for knowiaciga Advanced Web Programming 1-15 Refreshing Java Script and CSS 1B Gari Cn Sor Form Waroe eet lore QO > [el over temptencissenten —+|4] x] P = Pl Ge Fortes | oe E) Sogcied sts > Gre ane {8 Genwi Ci StF a-a- rome s> _*) Tongue Twister She sells sea shells on the sea shore. The shells she cells are sea shells, I'm sure. ARC if che sole s0s shall onthe seashore, ‘then cur ako ashore hell Note that the class selector must be preceded by a dot operator. ERE] ic Selectors ‘* The id selector is similar to the class selector but the only difference between the two is that class selector can be applied to more than one elements where as using the id selector the style can be applied to the one specific element. + The syntax of using id selector is as follows - ‘#name_of_id {property:value list;} + Following HTML document makes use of id selector HTML Document{idSel.htmt] <IDOCTYPE html> <b> ‘<head> <<title> id Selector TECHNIGAL PUBLIGATIONS® - An up thrust for knowiaciga ‘Advanced Web Programming 1-16 Refreshing Java Script and CSS Tes wfe mark uf an wducated mind tu fe whl rw entertain 4 thug switfent ecoepeing tt Asis This selector is denoted by * (asterisk). This selector can be applied to all the elements in the document. HTML Document[UniverSel.html] ‘TECHNICAL PUBLICATIONS® - An up thrust for knowledige Advanced Web Programming 1-17 Refreshing Java Script and CSS
  • friend in need is a friend indeed ‘
  • Cleanliness is next to Godliness
  • Allis fair in love and war ‘
  • An apple a day keeps the doctor away
  • God helps them who help themsslves


  • -From My Collection. Output (B Uriel Selector - Windows eet Explorer SMG 6 overne mmecctmcnt ls xP ences ] ‘Ue Fovortes | ofp (@) Suggested Stes ~ €) Get More Ad-ons = Brive elector Braco Famous Proverbs A friend in need isa friend indeed Cleaniness is next to Godliness Allis fain love and war ‘An apple a day keeps the doctor away (God helps them who help themselves From My Collection I Computer| Protected Mode Off ‘As we have defined the universal selector that sets the green color. Hence the text that is appearing on the above web page is in green color. EEE Attribute Selector * CSS allows authors to specify rules that match elements which have certain attributes defined in the source document. + The syntax is [att] -Match when the element sets the “att” attribute, whatever the value of the attribute. {att=val] - Match when the element's “att” attribute value is exactly "val". TECHNIGAL PUBLIGATIONS® - An up thst for knowiaciga Advanced Web Programming 1-18 Refreshing Java Script and CSS * Example : In the following example all the elements get selected with a target attribute. ‘

    The links with a target attribute gets a RED background:

    Google

    Output ([ditestintnl x cS © @ file///c:/tes.html Ow) do) = ‘The links with a target attribute gets a RED background: Google Facebook Contextual Selector * "Contextual selectors” in CSS allow you to specify different styles for different parts of your document. + You can assign styles directly to specific HTML tags, or you can create independent classes and assign them to tags in the HTML. TECHNIGAL PUBLIGATIONS® - An up thst for knowaciga ‘Advanced Web Programming Refreshing Java Script and CSS For example ~
    This line is in bold face font

    This line is in bold face with the color ofthe text - blue

    Good Bye

    /eijtestinten! €)> SO fieyj//a:/est.htmi OW) » ‘This line is in bold face font This line is in bold face with the color of the text - blue Good Bye EE Background Using background-image property an image can be set as background. HTML Document{Backimg.htmi] TECHNIGAL PUBLIGATIONS® - An up thrust for knowiaciga Advanced Web Programming 1-20 Refreshing Java Script and CSS < Background Image ‘ ‘

    Wonder of the World

    ‘The Vicorial waterfall is one of the greatest waterfalls in the world. It lies on the Zimbezi river which is between the border of Zambia and Zimbabwe. ‘The Victoria fall can be seen from 25 to 40 miles away. ‘The roaring of the water can be heard from a long distance. ‘The native people call it as “mosi-oa-tunya”, that means “smoke that thunders”. Victoria falls was discovered by David Livingstone in 1855. ‘The falls were named in honor of Queen Victoria.

    Output Os Ferm smmtangient 9 P Fortes =) [fase oe ge Saye Wonder of the World TECHNIGAL PUBLIGATIONS® - An up thrust for knowaciga Advanced Web Programming 1-21 Refreshing Java Script and CSS Itis expected that the foreground text over the image should be visible. That means the color of the background image must not be the same as the color of the text written over it. # Background-repeat property The background-image property sets the background image with repetition. If ‘we want to control the repetition of the image then we must set the background- repeat property. The values of this property could be no-repeat, repeat-x, repeat- y or repeat(default). The repeat-x means the background image gets repeated over the x-axis(horizontally) and repeat-y means the background image gets repeated over the y-axis(vertically). © Background-position property Various values for back-ground position property could be top, bottom, left and right (EERIE Write a CSS rule that places a background image halfway down the page, tilting it horizontally. The image should remain in place when the use scrolls up or down. Solution :

    ‘Twinkle, twinkle, litle star, How I wonder what you are.Up above the world so high, Like a diamond in the sky.Twinkle, twinkle, little star, How I wonder what you are! TECHNICAL PUBLIGATIONS® - An up thrust for knowaciga Advanced Web Programming 1-22 Refreshing Java Script and CSS When the blazing sun is gone, When there's nothing he shines upon,Then you show your little light, ‘Twinkle, twinkle, through the night. ‘Twinkle, twinkle, little star, How I wonder what you arel In the dark blue sky so deep Through my curtains often peep For you never close your eyes Til the morning sun does rise ‘Twinkle, twinkle, little star How I wonder what you are Twinkle, twinkle, little star How I wonder ‘what you are

    EEG Color and Color Properties Different browsers have different ability to deal with the colors. In the next subsequent sections we will discuss how to use colors using CSS. EEX] color Groups There are three groups of colors. Those are as given below - 1, This is the smallest group of colors. In this group there are 16 colors. These are named colors. The colors in this group are enlisted as follows - SrNo. ColorName Hexadecimal Value 1 black ‘000000 a red FFO000 3 lime OOFFOO 4 blue 000FF 5 yellow FEFFOO 6 fuchsia FFOOFF 7 aqua OOFFFF 8 white FFFFFF 9 silver ‘cococo 10 gray ‘808080 1 maroon ‘800000 12 purple 800080 TECHNIGAL PUBLIGATIONS® - An up thrust for knowaciga Advanced Web Programming 1-23 Refreshing Java Script and CSS 13 green 008000 4 olive 808000 15 navy 000080 16 teal 08080 These colors get displayed as it is on the web browsers. And all the web browsers support these colors. 2. There is a set of 216 colors which is called web palette. The elements of such colors are red, green and blue. The values of these elements can be 00, 33, 66, 99, CC and FF. 3. There are 16 millions colors. These are 24-bit colors. Syntax : Color : colorname : EEA Color Properties Using color property we can set the foreground color and using background-color the background color can be set. The use of these properties is shown in XHTML document. HTML Document{colorProperties.htmi] < Color Properties

    This is a green text with yellow background

    TECHNICAL PUBLIGATIONS® - An up thst for knowaciga Advanced Web Programming 1-24 Refreshing Java Script and CSS (2) Gator Adon | \pwrcermareees a- This is a green text with yellow background Manipulating Texts and Fonts The font properties can be setting different types of fonts, styles and sizes. Font Families The font-family denotes different types of fonts such as Arial, Times New Roman, Script, monospace and so on. Following are some examples of generic fonts Generic Font Name Example sans-serif Arial, Helvetica, Futura cursive Zapf-chancery fantasy Critter, Cottonwood ‘monospace Courier, Prestige serif Times New Roman,Garamond Let us see usage of font-family property in HTML document. HTML Document{FontFamily.htm!] Font Family Demo

    This text is in Arial ‘

    This text is in soript

    This text is in Times New Roman ‘

    This text is in fantasy

    This text is in Garamond If the font name has more than one word then the name should be enclosed by the single quotes. Although quotes are not mandatory, it is a good practice to use quotes for specifying the font name. F¥ Font Sizes This property is used to specify the size of the font. One can specify the font size in points (pts), pixels (px) or in percentage (%). We can also specify the font size using the relative values such as small, medium, large. Use of font size in such a way is relative. And the disadvantage of using such relative sizes is that one cannot have the strict control over the font-size. Different browsers may have different font size values. In the following HTML document we will use the font-size property. TECHNICAL PUBLIGATIONS® - An up thrust for knowiacige Advanced Web Programming 1-26 Refreshing Java Script and CSS HTML Document{FontSize.html] Font-Size Demo

    Programming the Web

    Programming the Web

    Programming the Web

    Programming the Web
    EW Font Variants The font variation can be achieved by making setting the font in upper case or in lower case. We use font-variant property for this purpose. Value Meaning normal The font can be displayed in normal form. small-caps The font can be displayed in small capital letters. TECHNIGAL PUBLIGATIONS® - An up thst for knowinciga ‘Advanced Web Programming 1-27 Refreshing Java Script and CSS * oblique The illustration is as given below - HTML Document[FontSt.htmi] ‘TECHNICAL PUBLICATIONS® - An up thust for knowledige Advanced Web Programming 1-28 Refreshing Java Script and CSS ‘Font-Style Demo

    Programming the Web

    Programming the Web

    Output @ Fort Sie Demo Window: nem Explorer GQO>X [Bove onplevenstinns |] x] P Togeev oun P =] ie Favors |p) Suggetea Stes +) GetMore Add-ons + | BionSyie dene a 5 Be Pager Soteye ” Programming the Web Programming the Web Programming the Web ‘omput [Protected Mode Off EJ Font Weights Various font styles are - * Normal (by default) * Bold * Bolder © Lighter The illustration is as given below - HTML Document[FontWt.htmi] Font-Weight Demo

    Programming the Web

    Programming the Web

    Programming the Web

    Output 1B Fon Woah Doms“ Wedows inert oer QO = [er over Samp ronewentn! Faveites | @) se (2) Get More Above B Fonteighe Demo Bet DT Re Pager Saye Programming the Web Programming the Web Programming the Web FJ Font Shorthands We can specify more than one font properties in a list For example HTML Document[Fontshrthnd.htm!] <Font Properties

    I Love my Countrylll

    @ Font Properties - Windows Internet Explorer GO = Fi overt compesronsnninarent =]%1 x] ors He Faves | Bp B)Suageted Sts = ) Get Mom Adore x (Boni cpa [| Rr Be Pager sey I Love my Country!!! iM Computer | Protected Mode: OFF Text Decoration Using text decoration property we can include special features in the text. Various properties of text decoration are © underline * overline * line-through HTML Document{TxtDecor.htmi] <Text Decoration

    This text is having linethrough

    This text is having overline

    This text is a normal text

    Output @ Tex Decorstion - Windows Intemet Explorer He 0) ov empetnadecacsart —~ 145] x] Peres] Be Favorites | Qe (2) Suggested Sites» ) Get More Add-ons ~ @ tex decoction MB ~ e Pager satay This tecti This texts having overine This text is having underline This text is a nommal text MM Computer| Protectes Moue: OFF EY Alignment of Text Using cascading style sheets we can align the text. This alignment can be done using following properties such as - Property Value Meaning text-align left Aligning the text to the left. text-align right Aligning the text to the right text-align center Alignment of text at the text-indent value in inches Desired indentation of the text canbe applied. TECHNIGAL PUBLIGATIONS® - An up thst for knowncige Advanced Web Programming 32. Refreshing Java Script and CSS Following is script which uses various text alignment properties. HTML Document[TextAlignCSS.htm!] Text Alignment Demo This line is aligned at left

This line is aligned at right

This line is aligned at oenter TECHNICAL PUBLIGATIONS® - An up thrust for knowaciga Advanced Web Programming 1-33 Refreshing Java Script and CSS Output @ Tost Rignment Demo - Windows Internet pore Ge Fevers | Wp B) Sungeted Ses ~ (2) Gt More Add-ons ~ (Brat Aigament Dore BR BS the Peper satay ‘This line is aligned at left This line is aligned at right This line Is allgned at center 1 Compute Protected Mode OF EE. Lists There are two types of lists - unordered list and ordered lists. The unordered lists are given by bullets. These bullets are of various types such as square and circle disk. For displaying the lists we use list-style-type property. For unordered list we can use property values such as * Circle * Disk * Square * None Let us see their illustration in the HTML document. HTML Document [list1.htmi] <Unordered List Demo

Following are the useful vegetables...

  • Canot
  • Cucumber
  • Spinach
TECHNIGAL PUBLIGATIONS® - An up thst for knowiaciga “Advanced Web Programming 1-34 Refreshing Java Scrit and CSS Output @ Unordered List Demo - Windows Internet Explorer Goo e ovema bampesusaren ~]4] xP a @ Unordered List Demo Sie Favorites | ly @) Suggested Sites ~ je) Get More Add-ons ~ fh > Bd Pages safetye = Carrot = Cucumber = Spinach Following are the useful vegetables... IM Computer| Protected Mode: Off There is another way of representing the unordered list. It is illustrated by following HTML document. HTML Documentflist2.html] <Unordered List Demo

Significance of Vegetables

  • It improves appearance of skin,hair and nail. It improves eyesight. It regulates blood sugar.
  • TECHNIGAL PUBLIGATIONS® - An up thst for knowinciga Advanced Web Programming 1-35 Refreshing Java Script and CSS

    • Cucumber
        It is useful in liver diseases. It controls diabetes.

          Spinach
            It serves as an anti-cancer agent. It is anti-aging vegetable.

            Output 1B ord Lk Dee Windows hier pee QO [eo or sete he Fovomes |e @) Sugoestes sues +g) Ge Mote | B Vnordaed it Dane sey cles] x]|P tveeveon P =| Significance of Vegetables + Cant © Teimproves appearance of skin har and nal « Ieimproves eyesight © Iteegults Blood sugar + Cuamniber * Tels wef in ver ceases + Ircomrole diabetes * Spinach © Teserves at an anti-cancer agent, + is ani-aging vegetable. 4 Its arch source of Viana A and C. TECHNIGAL PUBLIGATIONS® - An up thst for knoweciga Advanced Web Programming 1-36 Refreshing Java Script and CSS We can also display small images as the list item bullet. For example HTML Documenttist3.html] ‘Unordered List Demo ‘ ‘

            Indian Idols
            • Naranyan Murthy
            • Lata Mangeshkar
            • Abhinav Bindra
            • Sachin Tendulkar <AR.Rehman
            • @E Unortorent ise Deme —W neta Irtemer Faplorer QO - [el ova ra. srptena ot ~]4] x |[P toaneew cis 2 ~] Ge Favorites |e) jes iB) Get More Add ons + B tiodeetLs dem [| wh Pocen Sit” Indian Tdols B.Navanyan Many & Lata Mangeshkar & Abhinav Bindeo & Scctin Yendalcar ® ARRehoan I Computer | Protected Mode: OFF TECHNIGAL PUBLIGATIONS® - An up thst for knowinciga Advanced Web Programming 1-37 Refreshing Java Script and CSS Let us now make use of ordered list. For an ordered list various property values are enlisted below. Property Value ‘Sample preview decimal 1234 upper-alpha ABCD lower-alpha abed ‘upper-roman LILIIv Jower-roman HTML Documenttlist4.html] <ordered List Deme ol {list-style-type:decimal;} ol ol {list-style-type:upper-alpha;} ol ol ol {list-style-type:lower-roman;} ‘

              Vitamins in Fruits and Vegetables

              1. Fruit
                1. Apple
                  1. Vitamin A
                  2. Vitamin C
                2. Banana
                  1. Vitamin A
                  2. Vitemin B1
                  3. Vitamin C TECHNICAL PUBLIGATIONS® - An up thst for knowinciga Refreshing Java Script and CSS Advanced Web Programming
                3. Mango
                  1. Vitamin A
                  2. Vitamin E
              2. Vegetable
                1. Cabbage
                  1. Vitamin A
                  2. Vitamin B1
                  3. Vitamin B2
                  4. Vitamin C
                2. Cauliflower
                  1. Vitamin A
                  2. Vitamin B1
                  3. Vitamin C
                3. Potato
                  1. Vitamin A
                  2. Vitamin E
              TECHNIGAL PUBLIGATIONS® - An up thst for knowecige Advanced Web Programming 1-39 Refreshing Java Script and CSS Boas bore Wee ape Epo Oa oven toreetne — Se Fovontes | 3B) 0 Bedeedindene Vitamins in Fruits and Vegetables 1. Frit 1 Compa otiee Mode OF Ei Responsive Design Definition : “Responsive design” refers to the idea that your website should display equally well in everything from widescreen monitors to mobile phones. Itis called responsive web design because you can resize, hide, shrink, enlarge, or move the contents of the web page to make it look good on any screen. The responsive web design makes use of HTML and CSS only. It is neither a program nor a JavaScript. Using the responsive design approach the web developer can give the best experience for all the user. For example - TECHNIGAL PUBLIGATIONS® - An up thst for knowaciga Advanced Web Programming 1-40 Refreshing Java Script and CSS Desktop Mobile ohone Tablet Fig. 4.9.4 Responsive Layout for Different Devices ‘© There are four key components that make responsive design work - © Liquid Layouts © Scaling Images to the viewport size. ©. Setting viewports via tag. © Customizing the CSS for different viewports using media queries. ‘* Making the use of liquid layouts means specifying the widths in percentage. This is the most obvious part of any responsive web design approach. Scaling images to the viewport size means you have to specify following rule: img { ‘Width:100%; + * It only shrinks or expands the visual display of the image to fit the size of the browser window, never expanding beyond its actual dimensions. EEEI setting Viewports ‘© Viewport means user's visible area of web page. ‘© The viewport varies from mobile phone to desktop computers. * HTMLS allows the web developer to take control over the viewport using tag. TECHNIGAL PUBLIGATIONS® - An up thst for knowaciga Advanced Web Programming 1-41 Refreshing Java Script and CSS ‘* Following line must be included in your HTML document to set the viewport : aN ‘Sets the intial zoom Gives browser the 8 instruction to control Sets width of page as per level when the page is dimension of web page cialoserrede ‘rat loaded by he Fig. 1.9.2 The HTML document structure will be : * By setting the viewport in above manner, the page is telling the browser that no scaling is needed, and to make the viewport as many pixels wide as the device screen width. ‘© This means that if the device has a screen that is 320 px wide, the viewport width will be 320 px; if the screen is 480 px then the viewport width will be 480 px. EEE] Media Queries ‘* Another key component of responsive web design is media queries. Media queries is for different style rules for different size devices such as mobiles, desktops and so on. ‘* It uses the @media rule to include a block of CSS properties only if a certain condition is true. ‘* For example - Following HTML document makes use of media queries for different types of devices(such as mobile phones, tablets and desktops) HTML Document TECHNICAL PUBLIGATIONS® - An up thst for knowiecige Advanced Web Programming 1-42 Refreshing Java Script and CSS

              Resize the browser window and observe the change in color.

              Output ‘Petes hie € | D Aerstprs Ot)» |= Resize the browser window and observe the change in color. TECHNIGAL PUBLIGATIONS® - An up thrust for knownciga Advanced Web Programming 1-43 Refreshing Java Script and CSS 1. Write a short note on ~ Responsive design in HTML 2. Explain with illustrative example , how to set viewport? 3. What is media queries? Explain its use with the help of example, EEX) Bootstrap Introduction ‘* Bootstrap is open source, front end web framework. It is used for designing web- site and web applications. ‘* Bootstrap helps the developer to create responsive designs. Responsive web design means creating the web site which automatically adjusts itself to look good on all the devices. These devices range from small phones to large desktops screens. * Bootstrap includes HTML, CSS and JavaScript based design templates which includes forms, buttons, tables, navigation, modals and so on. Features of Bootstrap Setting up Environment There are two ways to use Bootstrap in a webpage. 1) The first way is to use a CDN or Content Delivery Network. Using bootstrap CDN means that we will not download and store the bootstrap files in our server or local machine. We will just include the bootstrap CSS and JavaScript links on our page. 2) The second way is downloading and storing a copy Bootstrap files in our web server or local machine. We can download the Bootstrap from https://getbootstrap.com/ Ihave created a folder named bootstrap-3.3.7 and downloaded my Bootstrap in this folder. After getting downloaded I can see three folders in it namely css, fonts and js ‘* If we want to use the CDN then we will include Bootstrap CSS as follows - ‘© If we want to use our own downloaded copy then we will use Similarly the jquery can be used as or ‘ TECHNICAL PUBLIGATIONS® - An up thst for knowaciga

You might also like