SlideShare a Scribd company logo
Instant Ebook Access, One Click Away – Begin at ebooknice.com
(Ebook) Practical Web Development by kan
https://ebooknice.com/product/practical-web-
development-50195080
OR CLICK BUTTON
DOWLOAD EBOOK
Get Instant Ebook Downloads – Browse at https://ebooknice.com
Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...
Start reading on any device today!
(Ebook) Learning Django Web Development_ From idea to prototype, a learner's guide
for web development with the Django application framework by kan
https://ebooknice.com/product/learning-django-web-development-from-idea-to-
prototype-a-learner-s-guide-for-web-development-with-the-django-application-
framework-50195350
ebooknice.com
(Ebook) The Complete Web Design Edition by kan
https://ebooknice.com/product/the-complete-web-design-edition-50194588
ebooknice.com
(Ebook) Practical Electronics for Inventors by kan
https://ebooknice.com/product/practical-electronics-for-inventors-50195098
ebooknice.com
(Ebook) JavaScript Cookbook, 2nd Edition_ Programming the Web by kan
https://ebooknice.com/product/javascript-cookbook-2nd-edition-programming-the-
web-50195402
ebooknice.com
(Ebook) Learning LibGDX Game Development, 2nd Edition by kan
https://ebooknice.com/product/learning-libgdx-game-development-2nd-
edition-50195342
ebooknice.com
(Ebook) Python, PyGame and Raspberry Pi Game Development by kan
https://ebooknice.com/product/python-pygame-and-raspberry-pi-game-
development-50196044
ebooknice.com
(Ebook) Complete Vue.js 2 Web Development: Practical guide to building end-to-end
web development solutions with Vue.js 2 by Mike Street, Andrea Passaglia, Paul
Halliday ISBN 9781789959901, 178995990X
https://ebooknice.com/product/complete-vue-js-2-web-development-practical-guide-
to-building-end-to-end-web-development-solutions-with-vue-js-2-7336226
ebooknice.com
(Ebook) HTML5 Game Development by Example: Beginner's Guide by kan
https://ebooknice.com/product/html5-game-development-by-example-beginner-s-
guide-50195518
ebooknice.com
(Ebook) Practical Webix: Learn to Expedite and Improve your Web Development by Frank
Zammetti ISBN 9781484233832, 1484233832
https://ebooknice.com/product/practical-webix-learn-to-expedite-and-improve-
your-web-development-6981952
ebooknice.com
(Ebook) Practical Web Development  by kan
(Ebook) Practical Web Development  by kan
Practical Web Development
Table of Contents
Practical Web Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The World Wide Web
World Wide Web
The Internet
HTTP and HTML
HTML
HTTP
The World Wide Web Consortium (W3C)
Mosaic
The first browser
Netscape
Internet Explorer
The explosion of the Web
Amazon.com and e-commerce
Google and Yahoo!
Social networking
Web development
HTML
HTML editors and other tools
Browsers and web servers
CSS
JavaScript
PHP
Data
Summary
2. HTML
HTML versions
Semantic and presentational HTML
The structure and syntax of an HTML document
Doctype
<html>
<head>
<body>
Syntax for tags or elements inside the document
HTML comments
Links
The <a> tag and attributes
The href attribute
The <a> name attribute
The <a> target attribute
Classic document elements
<h1>, <h2>, <h3>, … <h6> – headings
<p> – paragraph
<span> – span
Lists
Images
<img> element and attributes
Image width and height
Input forms
Form elements
Form attributes
The label attribute
Input attributes
The name attribute
The value attribute
The checked attribute
The readonly attribute
Textarea
Dropdown lists
The disabled attribute
The selected attribute
Tables
Table elements
<table>
<thead> <tbody>
<tr>
<th> <td>
Table attributes
colspan (td)
rowspan (td)
<div>, the "uebertag"
HTML entities
HTML5-specific tags
Summary
3. CSS
Adding styles to our documents
External style sheets
Internal CSS
Inline styles
The Document Object Model (DOM)
Selectors
Multiple classes
Descendants
Selecting children or siblings
Specificity
Block elements and inline elements
Colors
Fonts
So what are fonts?
Font families
Serif fonts
Sans-serif fonts
Monospace fonts
The font-family property
Font-weight and font-style
Font-size
Line-height
The box model
Padding
Border
Margin
Collapsing margins
Positioning
Float
position:relative
position:absolute
Styling lists
list-style-type
list-style-image
list-style-position
Styling anchors – pseudo-classes
Firebug
Summary
4. JavaScript
Programming 101
Compiled and interpreted languages compared
JavaScript is not the same as Java
Java
JavaScript
Our first JavaScript program
Variables
Variable declarations
Values of variables
Numbers
Strings
Converting strings to numbers
Expressions and operators
Arithmetic operators
Addition(+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulo (%)
Relational operators
Control flow
if
while
switch
Functions
Scope of variables
Objects
JSON
DOM objects, properties, methods, and events
The Window object
The Document object
write and writeln methods
Nodes and DOM traversing
Events
Summary
5. PHP
Introduction to PHP
Our first real PHP program
PHP and web hosting
Web hosting 101
Domain name
Web hosting companies
Server-side setup
Additional server-side services
PHP development environment
PHP as a web development language
Variables, values, operators, and expressions
Scope of variables
Local variables
Global variables
Static variables
String operators
To double quote or to single quote, that is the question
Control flow
Functions
String functions
strpos()
strlen()
substr()
Date functions
time()
date()
strtotime()
Arrays
Numeric arrays or indexed arrays
Associative arrays
Cool control statements for associative arrays
Sending data back to the server – forms
POST or GET, what should we get?
$_POST and $_GET arrays
Files
include, require, and require_once
Regular files
File functions or f-functions
fopen
file_exists(), is_file(), and is_dir()
fread and fwrite
One line at a time – fgets()
The printf family
Syntax of printf family of functions
Summary
6. PHP and MySQL
Databases
Relational databases
SQL
MySQL
phpMyAdmin
Creating databases
Creating and managing users
Creating and managing database tables
MySQLi in PHP
Connecting to the database
Our first SQL query, really!
Writing a MySQL query in PHP
Fetching the result
Obtaining data from more than one table
Adding data
Updating data
Summary
7. jQuery
Obtaining the jQuery library
Where to place the jQuery library on your page?
jQuery UI and jQuery Mobile
Using jQuery selectors and methods
html()
text()
attr()
.val()
show() and hide()
.find()
.parent()
.next()
.css()
jQuery documentation
Event handlers and jQuery
preventDefault()
$(this)
updateNewsContent()
Summary
8. Ajax
XMLHttpRequest
Ajax and jQuery
jQuery Ajax methods
$.load() method
$.post()
$.ajax()
Summary
9. The History API – Not Forgetting Where We Are
The problem we are trying to solve
The self-service restaurant
HTML5 History API and the history object
pushState()
popstate event
popstate and different browsers
The History plugin
Bookmarking
Summary
10. XML and JSON
XML
XML format
Displaying XML files
XML editors
XML Schema
SimpleXML
The XML file
The XML Schema file
The CSS file
The PHP file
Creating XML files with SimpleXML
Generating our HTML on the client side
XSLT
JSON
JSON syntax
JSON values
JSON objects
JSON strings
JSON arrays
JSON numbers
JSON and PHP
JSON with Ajax and jQuery
Two useful JSON methods
Summary
11. MongoDB
Relational database management systems
NoSQL databases
MongoDB
Installing MongoDB
The MongoDB shell
Creating databases, collections, and documents
_id and ObjectIds
Loading scripts
Removing documents
Updating documents
MongoDB data types
Basic data types
Dates
Embedded documents
One more example
MongoDB and PHP
Getting our gallery data
CRUD operations with MongoDB and PHP
Insert documents
Update documents
Queries with conditions
MongoDB cursor object
Summary
12. Mobile First, Responsive Design with Progressive Enhancement
Responsive design
Déjà vu
Media queries
Using the media attribute
Do more with less
Mobile first
Why mobile first?
We have come a long way
Mobile devices have newer capabilities
Mobile devices are not only used while on the road
Content first, navigation next
Small means big
Mobile input
Mobile first recap
Progressive enhancement
EnhanceJS
enhance.js
loadStyles and loadScripts
enhanced and FOUC
Modernizr
The Modernizr object
Polyfills and Modernizr
yepnope.js or Modernizr.load
Summary
13. Foundation – A Responsive CSS/JavaScript Framework
Our responsive toolkit – Foundation
Foundation components
The grid system
Class end
Visibility classes
The block grid system
Useful UI elements
Thumbnails – for simple galleries
Reveal modals – your better pop-up
Dropdowns
Example – a simple photo gallery
Accordions
Awesome Font awesome
Equalizer – the hardest thing to do with two <div>s made easy
Navigation
Top bar – not just your regular menu bar
Adding more magic
Yet more magic – off-canvas, the coolest thing
Summary
14. Node.js
Node.js
Installing node.js
npm
node
Adding HTML
Serving up static content
A tale of two (JavaScript) cities
node.js and MongoDB
Déjà vu … once more
Express
Installing Express
Our first Express app
An example with middleware
Templating and handlebars.js
Creating a layout
Our last Hello, World example
Summary
A. Bootstrap – An Alternative to Foundation
Bootstrap components
The Bootstrap grid system
Visibility classes
Buttons
Other UI elements
Thumbnails
Dropdowns
Modal – the Bootstrap popup
Combining dropdowns and modals
Collapse – an accordion for Bootstrap
Navigation
Summary
Index
Practical Web Development
Practical Web Development
Copyright © 2015 Packt Publishing All rights reserved. No part of this book
may be reproduced, stored in a retrieval system, or transmitted in any form or by
any means, without the prior written permission of the publisher, except in the
case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of
the companies and products mentioned in this book by the appropriate use of
capitals. However, Packt Publishing cannot guarantee the accuracy of this
information.
First published: July 2015
Production reference: 1240715
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78217-591-9
www.packtpub.com
Credits
Author
Paul Wellens
Reviewers
Jorge Albaladejo
Elvis Boansi
Adam Maus
Jesús Pérez Paz
Commissioning Editor
Edward Gordon
Acquisition Editors
James Jones
Sonali Vernekar
Content Development Editor
Ritika Singh
Technical Editor
Ryan Kochery
Copy Editors
Alpha Singh
Ameesha Green
Jasmine Nadar
Jasmine Nadar
Project Coordinator
Milton Dsouza
Proofreader
Safis Editing
Indexer
Rekha Nair
Production Coordinator
Manu Joseph
Cover Work
Manu Joseph
About the Author
Paul Wellens has been a senior product manager for a major computer company
in the Los Angeles area and Silicon Valley for over two decades. Before that, he
used to install Unix systems and train companies in Europe, from his native
Belgium. Later in his career, he became a web development aficionado because
it brought him back to another passion of his: programming.
This is not his first book. His prior publication is of a different nature. Nature is
what it is all about as it is a guidebook on Eastern California, which is illustrated
with his own photographs. Therefore, it should not come as a surprise to learn
that, besides experimenting with new web technologies, his major hobbies are
photography and hiking in the Eastern Sierra.
Acknowledgments
I have written books before and I know that the result can only be successful if
there are some nice people to assist you. This is the first time that I have worked
with a publisher, Packt Publishing, so these are the first people I would like to
thank. I would like to thank Shivani Wala for discovering me and James Jones
for working with me to figure out the right book for me to write and for you to
read. I enjoyed working with Priyanka Shah, Ritika Singh, and Ryan Kochery
who assisted me in bringing this cool project to completion, without a single
complaint, even though I was once again late with a deliverable. Thank you for
being so patient with me.
I would also like to thank (yes, this is a note of cynicism) the three companies
that "manage" the railroads in Belgium. Without their comedy of errors with
trains—delays, cancellations, failure to depart because of mechanical problems,
or trains departing from the station where you want to get to, as opposed to
depart from, I would never had so much time to work on this book on my iPad.
It is not in their honor, but, because for 2 years, it was the highlight of my day to
safely arrive at Antwerp Central Station—which was rated by an American
newspaper as the most beautiful train station in the world—that we decided to
use it as the cover photo.
Next, I would like to thank my web developer buddy, Björn Beheydt, for taking
the time to read the early versions of the chapters of this book and providing
constructive feedback. I would also like to mention Steve Drach and Bart
Reunes for always being there when I needed some technical advice.
Then, there are places that I would like to call a home away from home, where
folks did not mind that I was typing away on my Bluetooth keyboard when
inspiration kicked in. Most notably, I have to thank the folks at Trapke Op
(Caro, Maressa, Evi, Klaartje and Jill) in Brecht, Belgium, where I typed these
sentences. These wonderful people helped me make it to the finish line. Het
Boshuisje in Zoersel, where Hendrik Conscience wrote books over a hundred
years before I did, also comes to mind. I would like to thank Theo for always
giving me a seat to land with my iPad, keyboard, and work.
Less related to this book, but still in need of a mention, are all my friends in
California that inspired me to carry on doing great things in hard times. In
particular, I want to express my appreciation to the people that work(ed) at the
particular, I want to express my appreciation to the people that work(ed) at the
Gordon Biersch Restaurant in Palo Alto, which I can still proudly call my photo
gallery. I thank them for their support for over 11 years and for still welcoming
me when I visit them; they make me feel as if I only left last night. That also
includes the patrons of the place with whom I've had numerous conversations
and enjoyed every single one of them.
If you read this book, or my previous book, you will notice that I have a certain
affinity and passion for a particular part of California. So, I would like to thank
all the wonderful folks that live in the town of June Lake, California, for always
having inspired me to come back and be creative. My goal in life is to go there
as often as I can.
Finally, I would like to thank my mother. It has been hard for her since my father
passed away and her son returned. I am dedicating this book to her, not that I
expect her to read it, but I really appreciate the patience she had with me while I
was writing it.
About the Reviewers
Jorge Albaladejo is a software engineer with a master's degree in information
and communication technologies from HES-SO, Switzerland. With over a
decade of experience building cloud, SaaS, and web applications, he considers
himself to be a passionate and versatile full-stack web developer.
Throughout his professional experience, he has worked with many companies in
different fields, such as project management, social networks, quality assurance,
weather data visualization, and video games. He devours countless books about
software engineering, project management, and science fiction, and he is
passionate about clean, long-lasting software architectures.
He is currently working as a freelance contractor under the commercial name of
CometaStudio, and he is mostly interested in start-ups and mid-sized companies
that build great web experiences for great causes that make a difference. His next
dream is to become a digital nomad who travels around the globe while working
at the same time—and learn languages in the process!
Elvis Boansi is a software developer at John Jay College. He develops and
maintains custom web applications that are used by members of the college. In
his spare time, he enjoys playing soccer and basketball with his friends.
I'd like to thank my employers at John Jay College for all of their support. I
would also like to thank my supervisors, Ana and Juan, for their feedback. I
thank my friends, Sanga, Steve, and Loric, for constantly sharing their
knowledge with me.
Adam Maus is a software developer with a master's degree in computer science
and works at the Center for Health Enhancement Systems Studies at the
University of Wisconsin in Madison in the United States. His interests lie in
developing web technologies that utilize data mining to create better user
experiences. He primarily works on websites that help people undergoing
addiction recovery support, as well as people who are aging. In his free time, he
enjoys running, biking, and reading books.
Jesús Pérez Paz is a full-stack web developer with experience in project
management. He works at PepitaStore Inc. and collaborates with Mozilla.
His main area of work is design, and he integrates the user interface (or
frontend) of web pages / applications; however, lately, he has been diving into
backend stuff and has become a full-stack web developer.
He loves the open/free Internet and thinks that the Internet is a global public
resource that must remain open and accessible to everyone.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit
www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with
PDF and ePub files available? You can upgrade to the eBook version at
www.PacktPub.com and as a print book customer, you are entitled to a discount
on the eBook copy. Get in touch with us at <service@packtpub.com> for more
details.
At www.PacktPub.com, you can also read a collection of free technical articles,
sign up for a range of free newsletters and receive exclusive discounts and offers
on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online
digital book library. Here, you can search, access, and read Packt's entire library
of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to
access PacktLib today and view 9 entirely free books. Simply use your login
credentials for immediate access.
Preface
I am fortunate to have lived and worked in California for a long time. The
majority of that time, I lived in Palo Alto, which is the center of Silicon Valley,
the home of Stanford University, and the birthplace of many companies, big and
small, such as Sun Microsystems, where I worked. I sat on the front row to see
how the World Wide Web developed, as well as being present for the advent of
social media. Facebook started on the other side of the wall of my favorite
restaurant. Now, some Facebook guy or girl is sitting in what used to be my
office at the bottom of the Dumbarton Bridge. As a product manager for Solaris,
one of my tasks was to make sure that Netscape Navigator was included with our
operating system. So, I was right at the source in which the development of the
Web began. I even went to the Web 2.0 conference and bought the book of the
same name.
Then, I felt the need to have my own website to display my photographs and
inform people about the beauty and interesting places of the parts of California
that I had discovered during my many journeys travelling around the state. So, I
created one. One day, I was telling a friend about it and he tried to look at it on
his mobile phone. It looked terrible. So, I bought a Nokia phone (a brick
compared to what we have today) so that I could test my own site to make sure
that it looked good on a phone as well. This is how I caught the bug of
responsive design, years before someone started calling it this.
Upon my return to Belgium, I decided that it was time to learn as much as
possible (I love to learn new things) about what is out there beyond creating
websites and took a 6-month course on PHP web development. A lot of it looked
familiar as I was previously a UNIX and C developer. There were only 12
people in the class, who were all bright minds, and I quickly discovered that
there was more to learn.
As the classes took place in Leuven, a major university town in Belgium, I went
to the local university bookstore and bought book after book on all kinds of
related topics and quickly became a jQuery fan. jQuery, by the way, was not
even included in the course. I started wondering why someone needed to have 35
different books to learn about web development and that writing a single book
that gave a comprehensive overview of what you need to know to engage in web
development would not be a bad idea.
Since then, web development has changed a lot; more books were needed,
eBooks this time, but the concept remained the same. So, now you know why I
wrote the book.
This book gives you an overview of all the general aspects of web development,
in a traditional way, using plain HTML to do static websites, as well as the
current way, to enable you to create your web pages dynamically and make sure
that they look great on mobile devices as well, by using responsive design. We
conclude by giving you a hint of what is yet to come if you replace the
traditional web server by writing your own using node.js.
What this book covers
Chapter 1, The World Wide Web, gives you an overview of the history of what
we know today as the World Wide Web.
Chapter 2, HTML, introduces HTML and gives you an overview of the most
commonly used HTML tags to do web development. You will be able to create a
basic website after reading this chapter.
Chapter 3, CSS, explains how to use Cascading Style Sheets (CSS). This is used
for the presentation part or layout of your website, from color to dimensions to
typefaces. The most commonly used CSS properties are explained here. Once
you are done with this chapter, you will be able to make your basic website look
good.
Chapter 4, JavaScript, first gives you an introduction to the world of
programming and programming languages. Next, the overall syntax of
JavaScript and how to use it for client-side programming is introduced.
Chapter 5, PHP, explains PHP, which is another programming language. This
one is used to do server-side programming. It requires a web server to do the
development of your website and deploy it. You will learn how to dynamically
create your web pages, rather than having to write a bunch of HTML files.
Chapter 6, PHP and MySQL, introduces MySQL, an open source database. You
will learn how to create a database, manage it using the phpMyAdmin tool, and
perform basic CRUD (create, replace, update, delete) operations from within a
PHP program.
Chapter 7, jQuery, covers a popular JavaScript library. It allows you to write
more compact and clean code and handles browser incompatibilities for you.
With this, it is going to be a lot easier and faster for you to write JavaScript code
that traverses and manipulates the web page. It does so by using selectors, which
you learned to use with CSS. So, with jQuery, you can write JavaScript code
without having to learn a lot of JavaScript.
Chapter 8, Ajax, introduces Ajax. It represents a collection of techniques to make
it easy to dynamically change only portions of a website. With this chapter, we
have entered the world of what I call "modern web development". The interface
that we use for our Ajax calls is jQuery.
Chapter 9, The History API—Not Forgetting Where We Are, explains a very
important piece of the web development puzzle. Once we are changing pages on
the fly so they look different but actually remain the same page (URL), strange
things can happen when visitors want to go back to what they think is the
previous page. A solution for this is described here that will not only work for
HTML5 but for HTML4 as well.
Chapter 10, XML and JSON, describes XML and JSON. They are two popular
formats to exchange data, for example the server and the client. Although XML
is used in a variety of environments, JSON is closer to the web development
community.
Chapter 11, MongoDB, describes an alternative to MySQL as a database. This is
a so-called NoSQL database and a document database. Documents are
conveniently in the JSON format. Here, how to access a MongoDB database
from within a PHP program is described.
Chapter 12, Mobile First, Responsive Design with Progressive Enhancement,
has the longest chapter title of the book. It explains how modern web
development has to be done now that more people are using mobile devices
instead of traditional computer screens to go to websites.
Chapter 13, Foundation – A Responsive CSS/JavaScript Framework, describes
most of the features of the Foundation framework, which helps you with your
responsive design. It contains everything that I have always wanted to write
myself but never had the time to do. This concludes the part of the book that
covers what I call modern web development.
Chapter 14, Node.js, gives an overview of what I call the avant-garde of web
development. It introduces node.js, which allows you to write your server-side
code in JavaScript, including your own web server, which is facilitated by using
the Express framework.
Appendix, Bootstrap – An Alternative to Foundation, describes the popular
CSS/JavaScript framework, which is an alternative to Foundation to help you
with responsive design. The main reason to include this is to point out key
differences and similarities.
The online chapter, The Mono County Site, provides a full example of a website
or application where we apply most, if not all, the things we learned. It is
available at
https://www.packtpub.com/sites/default/files/downloads/B03816_Appendix.pdf.
What you need for this book
You will need the following software to work with the examples in this book:
Software Source
Firefox and Firebug http://www.mozilla.org
Apache Web Server Part of the OS
XAMPP (includes MySQL and
PHPMyAdmin)
http://www.apachefriends.org
MySQL http://www.mysql.com
PHPMyAdmin phpmyadmin.net
jQuery http://www.jquery.com
The History jQuery plugin https://github.com/browserstate/history.js
MongoDB mongodb.org
Foundation foundation.zurb.com
Node.js nodejs.org
Bootstrap getbootstrap.com
Who this book is for
This book is for anyone who wants to get to grips with the broader picture of
web development today. It is perfect for beginners who want to get started and
learn web development basics, such as HTML, but it also offers experienced
developers a web development road map that will help them to extend their
capabilities and gain a greater insight into how different technologies interact
and work together.
Conventions
In this book, you will find a number of text styles that distinguish between
different kinds of information. Here are some examples of these styles and an
explanation of their meaning.
Code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles are shown
as follows: "We can include other contexts through the use of the include
directive."
A block of code is set as follows:
<body>
<div id="header"></div>
<div id="container">
<div id="left"></div><div id="middle"></div><div id="right"></div>
</div>
<div id="footer"></div>
</body>
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
<tag class="value1 value2">text<?tag>
Any command-line input or output is written as follows:
{ "key" : { "name":"Schwarzenegger","first":"Arnold",
"profession":"governator" } }
New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "
Now, not until a user clicks the Beach button, Hello, World will turn into Hello,
Beach."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think
about this book—what you liked or disliked. Reader feedback is important for us
as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <feedback@packtpub.com>, and
mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either
writing or contributing to a book, see our author guide at
www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.
Downloading the example code
You can download the example code files from your account at
http://www.packtpub.com for all the Packt Publishing books you have
purchased. If you purchased this book elsewhere, you can visit
http://www.packtpub.com/support and register to have the files emailed directly
to you.
Errata
Although we have taken every care to ensure the accuracy of our content,
mistakes do happen. If you find a mistake in one of our books—maybe a mistake
in the text or the code—we would be grateful if you could report this to us. By
doing so, you can save other readers from frustration and help us improve
subsequent versions of this book. If you find any errata, please report them by
visiting http://www.packtpub.com/submit-errata, selecting your book, clicking
on the Errata Submission Form link, and entering the details of your errata.
Once your errata are verified, your submission will be accepted and the errata
will be uploaded to our website or added to any list of existing errata under the
Errata section of that title.
To view the previously submitted errata, go to
https://www.packtpub.com/books/content/support and enter the name of the
book in the search field. The required information will appear under the Errata
section.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very
seriously. If you come across any illegal copies of our works in any form on the
Internet, please provide us with the location address or website name
immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com> with a link to the suspected
pirated material.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
<questions@packtpub.com>, and we will do our best to address the problem.
Chapter 1. The World Wide Web
This book talks about the past, present, and future of Web Development.
Beginning with Chapter 2, HTML, we will walk you through all the technologies
you need to know about, in order to practice web development. Before we do
that, we want to set the stage, so that we all know which Web we are talking
about: this would be the World Wide Web (www).
World Wide Web
I love history! So let us start with a little history about the World Wide Web. I
was fortunate enough to be able to work at a company that developed the first
commercial version of the UNIX Operating System. They were founded in 1977
and I joined them ten years later. UNIX is an Operating System (the thing you
need to make your computer do something) that was intended to run on
minicomputers (although they were called that, they could not fit into your
apartment and required air-cooling). These computers were typically used as an
isolated system that had quite a number of text-based terminals attached to them.
Today UNIX lives on, and forms the basis of Linux, Solaris, MacOS, and others.
Our company spotted an opportunity to add products that would add features and
technologies that today are standard. Some of these examples are email (ability
to send a mail to a person on another computer), and ftp (ability to transfer a file
to another computer, or to just access another computer). Yes, you had to pay
extra if you wanted to be able to send mail. Thanks to the Internet, all of this was
made possible.
The Internet
The Internet is a global network that today interconnects billions of computers
worldwide. Its origin dates back to research done for the US government, but
today everybody can get on the Internet, using its standard set of protocols,
commonly referred to as TCP/IP (the IP here being Internet Protocol).
Every computer or device that is connected to the Internet will have a unique
Internet address, aka IP address. It is a set of 4 numbers separated by dots, for
example, 192.25.13.90. Of course, you will never tell your friend that you
bought something at 192.25.13.90 but at, for instance, www.amazon.com. This
is because the Internet also uses a feature that translates IP addresses into easier
to remember domain names. The example I used happens to be a website you
can go to and buy things from a practice that we all know has caused the www to
become what it is today.
The Internet and the www are, in everyday speech, treated as if they are
synonyms but they are indeed not. There are a lot of different services provided
on the Internet (by companies called Internet Service Providers (ISP)), and
that was already the case before the www existed (for example, giving you
access to electronic mail). What it took for the www to emerge was (just like in
JavaScript) a series of asynchronous events. Two of those are too important to
not mention.
HTTP and HTML
You have probably heard this story many times, but the World Wide Web would
not have existed without it. It is the story of Tim Berners Lee, an engineer at the
European Centre for Nuclear Research (CERN). The centre had many
computers that were, of course, hooked up to the Internet. It also produced a
tremendous amount of data and documents, and that became almost impossible
to manage. Tim worked out a solution by developing a language to write these
documents in, a protocol on top of the Internet to manage them, as well as a
computer program for users to access them.
HTML
HTML, short for Hypertext Markup Language is the name of that language.
Hypertext is text that contains hyperlinks, which in turn are those parts of a
document which readers can click on to take them to a different document, using
the link. You have all seen the blue underlined parts of a text, in not-so-good-
looking web pages. These are hyperlinks.
A document in HTML consists of tags, with text in between them. There are
opening and closing tags for example, as follows:
<h1>Hello, world</h1>
Here, <h1> is the opening tag and </h1> the closing one. We will learn about a
similar markup language: XML. HTML and XML are not the same though. One
important difference is that in XML you can define your own tags, as long as
you close each one you've opened. XML is used to transfer the data and the tags
are used to organize the data.
In HTML, tags do have a specific meaning. <h1> would be used in a document
for the text of a level one header. A <a> tag—the anchor tag—is the one used to
include the hyperlinks we just discussed. So the purpose of writing HTML is not
to transfer data, but to present it to human users.
To do so, these tags are interpreted by the computer program we mentioned
earlier. Such a program is called a browser. When the reader clicks on a
hyperlink, the browser will detect that as well, and send a request to yet another
program, the web server, to go fetch another document.
Other documents randomly have
different content
The tailor went and bought a suit of clothes for him. She put them
on him. He and the tailor went to the shop.
“Here’s a young man I have got for you,” said she.
He hired the young man for a year. The young man came to him
and was serving him well. Better was the learning that he had than
the shopman’s. The tailor was content as they were together. They
were the two comrades; nor did he ever recognise the tailor. They
were a couple of years in the city. One day the tailor said they were
there long enough, and would go home for a while now. He said he
would never go home. She said she would, that they would get a
place as good as to be there. They got ready and were drawing
towards Dublin. The clerk said he would not go near the city. She
said she would go. They walked on till they came to the city. There
was no going through the street for the clerk. He became sorrowful
and troubled. They were walking till they came to the house they
used to live in.
“This is a good house,” said the tailor; “we’ll go in to see if they
will keep us for the night.”
“We will not go into that house on any account.”
“We’ll go to no other place but that,” said the tailor.
They went in and got place till morning. The captain was living
there always. There were gentlemen dining with him. The tailor was
making fun for the girls in the kitchen. He began dancing and
singing. The clerk was sitting under the window, with his head bent
down. When the gentlemen heard the singing and the dancing in the
kitchen, they opened the parlour door to see the tailor playing his
music. They bade him come up to the parlour, to themselves. He
said he would like to have his companion with him. They bade the
two come. The two went up. They got whiskey. They made the tailor
sing. He was performing a while. He looked about him.
“This is a fine house you have,” said he. “I have travelled far
enough, but I never in my travellings met with a better house than
this of yours.”
“Simply I got this house.” He told the gentlemen how he came into
the house.
“Well,” said the tailor, “you bear witness to everything you have
heard. I was the woman, that was in the house, to whom that
happened.”
She opened her bosom to show it was a woman.
“Get up, you gillie over there.” She locked the parlour door. Kayleh
went for the police. The police came. They arrested the captain. The
gentlemen were witnesses. The captain was put in prison. She put
off the tailor’s clothes then. They arrested the maid and put her in
prison. They fell into their house and place again. They were then as
they were ever. The report went out through the city that Kayleh and
the king’s daughter were in their own house again. The king then
made a dinner and invited them to it. They were eating and drinking
for three nights and three days.
[10] Or “Spouse of Poverty.”
SIMON AND MARGARET.
Narrator, Michael Faherty, Renvyle, co. Galway.
Long ago there was a king’s son called Simon, and he came in a
ship from the east to Eire. In the place where he came to harbour he
met with a woman whose name was Margaret, and she fell in love
with him. And she asked him if he would take her with him in the
ship. He said he would not take her, that he had no business with
her, “for I am married already,” said he. But the day he was going to
sea she followed him to the ship, and such a beautiful woman was
she that he said to himself that he would not put her out of the ship;
“but before I go farther I must get beef.” He returned back and got
the beef. He took the woman and the beef in the ship, and he
ordered the sailors to make everything ready that they might be
sailing on the sea. They were not long from land when they saw a
great bulk making towards them, and it seemed to them it was more
like a serpent than anything else whatever. And it was not long till
the serpent cried out, “Throw me the Irish person you have on
board.”
“We have no Irish person in the ship,” said the king’s son, “for it is
foreign people we are; but we have meat we took from Eire, and, if
you wish, we will give you that.”
“Give it to me,” said the serpent, “and everything else you took
from Eire.”
He threw out a quarter of the beef, and the serpent went away
that day, and on the morrow morning she came again, and they
threw out another quarter, and one every day till the meat was
gone. And the next day the serpent came again and she cried out to
the king’s son, “Throw the Irish flesh out to me.”
“I have no more flesh,” said the prince.
“If you have not flesh, you have an Irish person,” said the serpent,
“and don’t be telling your lies to me any longer. I knew from the
beginning that you had an Irish person in the ship, and unless you
throw her out to me, and quickly, I will eat yourself and your men.”
Margaret came up, and no sooner did the serpent see her than
she opened her mouth, and put on an appearance as if she were
going to swallow the ship.
“I will not be guilty of the death of you all,” said Margaret; “get
me a boat, and if I go far safe it is better; and if I do not go, I had
rather I perished than the whole of us.”
“What shall we do to save you?” said Simon.
“You can do nothing better than put me in the boat,” said she,
“and lower me on the sea, and leave me to the will of God.”
As soon as she got on the sea, no sooner did the serpent see her
than she desired to swallow her, but before she reached as far as
her, a billow of the sea rose between them, and left herself and the
boat on dry land. She saw not a house in sight she could go to.
“Now,” said she, “I am as unfortunate as ever I was. There is no
place at all for me to get that I know of, and this is no place for me
to be.” She arose and she began to walk, and after a long while she
saw a house a good way from her. “I am not as unfortunate as I
thought,” said she. “Perhaps I shall get lodging in that house to-
night.” She went in, and there was no one in it but an old woman,
who was getting her supper ready. “I am asking for lodging till
morning.”
“I will give you no lodging,” said the old woman.
“Before I go farther, there is a boat there below, and it is better
for you to take it into your hands.”
“Come in,” said the old woman, “and I will give you lodging for the
night.”
The old woman was always praying by night and day. Margaret
asked her, “Why are you always saying your prayers?”
“I and my mother were living a long while ago in the place they
call the White Doon, and a giant came and killed my mother, and I
had to come away for fear he would kill myself; and I am praying
every night and every day that some one may come and kill the
giant.”
The next morning there came a gentleman and a beautiful woman
into the house, and he gave the old woman the full of a quart of
money to say paters for them till morning. The old woman opened a
chest and took out a handsome ring, and tried to place it on his
finger, but it would not go on. “Perhaps it would fit you,” said she to
the lady. But her finger was too big.
When they went out Margaret asked the old woman who were the
man and woman. “That is the son of a king of the Eastern World,
and the name that is on him is Stephen, and he and the woman are
going to the White Doon to fight the giant, and I am afraid they will
never come back; for the ring did not fit either of them; and it was
told to the people that no one would kill the giant but he whom the
ring would fit.”
The two of them remained during the night praying for him, for
fear the giant should kill him; and early in the morning they went
out to see what had happened to Stephen and the lady that was
with him, and they found them dead near the White Doon.
“I knew,” said the old woman, “this is what would happen to
them. It is better for us to take them with us and bury them in the
churchyard.” When they were buried, “Come home,” said the old
woman, “and we’ll know who is the first person comes the same way
again.”
About a month after a man came into the house, and no sooner
was he inside the door than Margaret recognised him.
“How have you been ever since, Simon?”
“I am very well,” said he; “it can’t be that you are Margaret?”
“It is I,” said she.
“I thought that billow that rose after you, when you got into the
boat, drowned you.”
“It only left me on dry land,” said Margaret.
“I went to the Eastern World, and my father said to me that he
sent my brother to go and fight with the giant, who was doing great
damage to the people near the White Doon, and that my wife went
to carry his sword.”
“If that was your brother and your wife,” said Margaret, “the giant
killed them.”
“I will go on the spot and kill the giant, if I am able.”
“Wait till I try the ring on your finger,” said the old woman.
“It is too small to go on my finger,” said he.
“It will go on mine,” said Margaret.
“It will fit you,” said the old woman.
Simon gave the full of a quart of money to the old woman, that
she might pray for him till he came back. When he was about to go,
Margaret said, “Will you let me go with you?”
“I will not,” said Simon, “for I don’t know that the giant won’t kill
myself, and I think it too much that one of us should be in this
danger.”
“I don’t care,” said Margaret. “In the place where you die, there
am I content to die.”
“Come with me,” said he.
When they were on the way to the White Doon, a man came
before them.
“Do you see that house near the castle?” said the man.
“I see,” said Simon.
“You must go into it and keep a candle lighted till morning in it.”
“Where is the giant?” said Simon.
“He will come to fight you there,” said the man.
They went in and kindled a light, and they were not long there
when Margaret said to Simon,—
“Come, and let us see the giants.”
“I cannot,” said the king, “for the light will go out if I leave the
house.”
“It will not go out,” said Margaret; “I will keep it lighted till we
come back.”
And they went together and got into the castle, to the giant’s
house, and they saw no one there but an old woman cooking; and it
was not long till she opened an iron chest and took out the young
giants and gave them boiled blood to eat.
“Come,” said Margaret, “and let us go to the house we left.”
They were not long in it when the king’s son was falling asleep.
Margaret said to him, “If you fall asleep, it will not be long till the
giants come and kill us.”
“I cannot help it,” he said. “I am falling asleep in spite of me.”
He fell asleep, and it was not long till Margaret heard a noise
approaching, and the giant cried from outside to the king’s son to
come out to him.
“Fum, faw, faysogue! I feel the smell of a lying churl of an
Irishman. You are too great for one bite and too little for two, and I
don’t know whether it is better for me to send you into the Eastern
World with a breath or put you under my feet in the puddle. Which
would you rather have—striking with knives in your ribs or fighting
on the grey stones?”
“Great, dirty giant, not with right or rule did I come in, but by rule
and by right to cut your head off in spite of you, when my fine,
silken feet go up and your big, dirty feet go down.”
They wrestled till they brought the wells of fresh water up through
the grey stones with fighting and breaking of bones, till the night
was all but gone. Margaret squeezed him, and the first squeeze she
put him down to his knees, the second squeeze to his waist, and the
third squeeze to his armpits.
“You are the best woman I have ever met. I will give you my court
and my sword of light and the half of my estate for my life, and
spare to slay me.”
“Where shall I try your sword of light?”
“Try it on the ugliest block in the wood.”
“I see no block at all that is uglier than your own great block.”
She struck him at the joining of the head and the neck, and cut
the head off him.
In the morning when she wakened the king’s son, “Was not that a
good proof I gave of myself last night?” said he to Margaret. “That is
the head outside, and we shall try to bring it home.”
He went out, and was not able to stir it from the ground. He went
in and told Margaret he could not take it with him, that there was a
pound’s weight in the head. She went out and took the head with
her.
“Come with me,” said he.
“Where are you going?”
“I will go to the Eastern World; and come with me till you see the
place.”
When they got home Simon took Margaret with him to his father
the king.
“What has happened to your brother and your wife?” said the
king.
“They have both been killed by the giants. And it is Margaret, this
woman here, who has killed them.”
The king gave Margaret a hundred thousand welcomes, and she
and Simon were married,[11] and how they are since then I do not
know.
[11] Simon’s wife, mentioned at the beginning of the story, has
apparently been forgotten.
THE SON OF THE KING OF PRUSSIA.
Narrator, P. M’Grale, Achill, co. Mayo.
There were giants at that time, and every seven years three
daughters of kings were left to them to be eaten, unless some one
were found to fight them. In this year the kings came together, and
they cast lots to see which of them should give his children to the
giants to be eaten. And the lot fell on the High King of Erin to give
his three daughters to the giants. Then came the son of the King of
Prussia to ask the king’s daughter in marriage, and the king said he
could not give her to him unless he would fight the giants, and he
said he would fight if he got good feeding.
And the king asked him, “What sort of food would you like best?”
Said he, “Marrow of deer and sinews of beeves.” And the king said
he would give him that.
There were servants killing for him his sufficiency of food, and he
rose out, the son of the King of Prussia, and he went among the
work-people, and when he would strike one of them a blow of his
fist and kill him the king would not say anything for fear of making
him angry. Then, when he came within a month of the time, he went
to the glen, and tools with him to make a hole in the glen, and he
was at home every evening, and he dirty.
When it came within a week of the time, the son of the King of
Scotland spoke to his father. Said he, “A good neighbour to you was
the King of Erin ever.”
“Good he was, my son, and I to him likewise.”
“And he never put war nor battle on you.”
“Nor I on him, my son.”
“I am making one request of you, father.”
“Every request you make of me I will give you, except to go to
fight in Erin.”
“Won’t you give me that, father?”
“I have fear of your getting married.”
“My hand and my word to you, father, that that woman I will not
wed till I come back to you.”
“With that request, go, and I will give you my blessing.”
He went with himself, then, and he arrayed himself in his clothes,
and the stars of the son of a king by a queen were on the breast of
his coat, and a poor man’s suit outside, till he came to the sea, and
took a great ship, till he came to Erin, and drew up his ship on the
land, and put on her fastening for a day and a year, though he might
chance to be there but an hour.
He went then to the house of the hen-wife, and asked for lodging;
and he got lodging for the night; and the old woman asked him
what was the news, and he said he had no news at all unless he
would get it from her.
“I’d say,” said she, “that it was under a docking you came out,
when you’ve heard nothing of the great gathering that’s to be here
to-morrow. There are three giants to come, on three days, one after
the other, and they are to get the three daughters of the King of
Erin, and the son of the King of Prussia, is to fight for them; and, if
he kills the giants, the first person to-morrow that brings the news
the giant’s head is cut off, will get a shovel of gold.”
Then the poor man and the hen-wife spent the night pleasantly,
and in the morning he got up and washed his hands and his face,
and ate his breakfast, and went to the glen, and he sat down in a
clump of ferns, brambles, and nettles, and there was he.
Then the king and his people went drawing to the glen, and when
they were near it the son of the King of Prussia told them to go
home, for fear the giant might come and kill some of them before he
could stop him. The king and his people went home and left the son
of the King of Prussia and the young girl in the glen, and she sat
down on a stone chair, and the son of the King of Prussia was
coming about her, thinking to make free with her, till he ran to his
hole and left her there.
Then he saw the ship coming under sail, three lengths before she
came near to land, and the giant cast anchor, and gave a step on
the land, and he all but sank the ship after him; and the land, when
he came on it, shook so greatly that the old castles fell, and the
castles that were made last stooped; every (old) tree was broken,
and the young tree was bent; and he left not foal with mare, nor calf
with cow, nor lamb with sheep, nor hare in a bush, nor rabbit in
hole, that didn’t go off in terror. And he came up to the girl and put
the tip of his finger under the edge of her girdle, and threw her over
the tip of his shoulder.
“My mischief and misfortune! Hadn’t your father a man, cow-boy
nor sheep-boy, to-day to fight me? Or where is the son of the King
of Prussia, who has been feeding for a year to fight me? Don’t think
it’s on feather beds I’ll put you, nor up the stairs, when I bring you
home; but you are big for one bite and small for two, and if I had a
grain of salt I would eat you at one bite; and small is the morsel you
are between myself and my two brothers.”
He went with her, drawing to the ship to get on board; and the
son of the King of Scotland spoke to him, and said he should not get
her like that without fighting. And the giant said that it wasn’t worth
his while to let her out of his hands, but for him to come and
prevent him taking her with him. But the other man said that was
not right, that he should put the woman down on the land, and fight
honourably. And then the giant asked him which he liked best,
wrestling on the red flagstones, or green knives at the top of his
ribs. He said that he liked best wrestling on the red flagstones, in
the place where his noble white feet should be rising above the
giant’s clumsy club feet. The two champions caught hold of each
other in the grip of the close, keen wrestling. If you were to go
seeking for sport from the west of the world to the world’s
beginning, it is to that pair you would go. They made soft of the
hard, and hard of the soft, till they drew the springs of fresh water
under the red stones; till the son of the King of Scotland
remembered that he came there without the King of Erin knowing,
nor his daughters, that he was come; and also that his father was
not pleased with his coming; and he gave the giant a squeeze, and
put him down to his two knees in the ground, and the second
squeeze to the waist of his trousers, and the third squeeze to the
back of his neck.
“A green sod over you, churl!”
“Stay, stay! best of champions that ever I saw. I am but a third of
the world, and my brother is the half of the world, and the other is
as strong as the world; and if you spare me, I and my brothers will
be your helpers, and we will conquer the world.”
“That’s not what I will do,” said the son of the King of Scotland;
“but I will cut the head off you.”
And he caught hold of his sword and cut the head off the giant.
And the young girl all the time was watching the young champion;
and she ran to him and kissed him, and asked him if he would come
home with her, and he said he would not come. She took a pair of
scissors and cut away a piece of the champion’s suit that was on
him.
He went with himself then, and came to the hen-wife, and told her
that the giant’s head was cut off; and she asked him if any one was
before her to the king with the news. And she ran to the king and
told him the giant’s head was cut off, and he gave her a shovel of
gold as the reward of her trouble.
When the son of the King of Scotland was gone, the son of the
King of Prussia arose out of his hole, and he took with him a book
and a knife, and he swore that unless she said it was he had done
the action, he would cut the head off her father and every one of
them. He took his sword and he cut a piece from the giant’s head,
and took it home in proof that he killed the giant.
The king came and his hosts before him, and they raised him on
their shoulders and carried him home. And there was great joy on
the king and his people that the giant was killed; and the two other
sisters were cheerful; but there was dissatisfaction and sorrow and
trouble on the third sister, and she spoke not a word to them except
to say, “You will have it yet.”
The king spent the night cheerfully, till the whiteness of the day
came upon the morrow.
The next day the second sister went out, and the son of the King
of Scotland fought for her, and when he would not go home with
her, she cut off a lock of his hair; but the son of the King of Prussia
said it was he killed the giant. And the next day the third sister went
out, and the son of the King of Scotland killed the third giant. The
girl asked him would he go home with her, and he said he would
not, and she took with her one of his shoes.
And when the son of the King of Prussia went home, and the third
giant killed by the son of the King of Scotland, proclamation was
made of the marriage of the son of the King of Prussia, and the
daughter of the King of Erin. And when they ate their supper, word
was sent to the priest of the pattens and the clerk of the table, (to
come) to marry them. And the hen-wife came and the champion to
the wedding; and they arose that the pair might be married. The
priest asked the girl if she would marry that man, and she said she
would not. And he struck her a box with his fist, and said, “How do
you know that you are my choice? Haven’t I my choice of the family
to get?” And the king said he had.
Then came the second daughter, and the priest asked her, would
she marry him? and she said she would not. And he struck her a
blow of his fist, and he said, “How do you know that you are my
choice? Haven’t I my choice of you to get?” And the king said he
had.
Then came the third girl, and the priest asked her, would she
marry him? and she said she would not. And the son of the King of
Prussia gave her a blow of his fist, and he said, “How do you know
that you are my choice? Haven’t I my choice of you to get?” And the
king said he had.
Then the Scotchman got up and he gave the son of the King of
Prussia a blow with the tip of his boot and knocked him down. And
the king offered a reward of five pounds to whoever would tell who
struck the champion. And, as there were bad people present, he was
told it was the old man down there who had struck him. He was
caught, and he was bound, and when the daughters saw him they
knew him, and they threw themselves on their knees before their
father and begged he would grant them one request; and he said he
would, but that one of them must marry the man.
“It is not for that man we are asking, but for this one, who saved
us.”
He put the three daughters in three rooms, and he called the
eldest, and she came to him and told him that he was the man who
saved her. She put her hand in her pocket and she took out the
piece she cut from his champion’s suit, and it answered to the coat.
Then the king called the second daughter, and she said likewise, and
showed the lock of hair, and her father was satisfied. He called the
third daughter, and she showed the shoe, and she said she had no
fear of him, that he it was who saved her.
The Scotchman got up standing, and he bound the son of the King
of Prussia, and they were going to put him to death. Then the
daughters asked the son of the King of Scotland if he would marry
any of them, and he said that to one of them he was bound; but
that when he knew what the son of the King of Prussia was going to
do he came without[12] his father’s leave to Erin to save them, “and
I cannot marry a woman till I go to my father and then I will come
back to you.”
And the daughter said, “Marry one of us and then go to your
father, and then you can come back.”
He said he could not do that, that he would go to his father first.
Said she,—
“If you do not marry one of us, I will put you for a year under
disesteem and bad esteem; every one will be spitting on you and
cursing you; whoever is meanest you shall be under his curses; and
till you marry one of us, or get cause for laughter, your mouth to be
at the back of your head.”
And when he saw that, “If I were going this hour to marry you, I
would not marry you now.”
The disfigurement came on him. He turned to the door and
opened his hand, and all that were between him and the door he
killed. He went on from place to place in hopes of getting a cure for
himself, and he left not a doctor in the place that he was not getting
the water of healing and every sort of drugs from them.
He was going till a man met him who was giving food and work to
every one, and he went to him and asked him for work. The man
said he would give it if the workmen would take him. He had
eighteen men, six of them each in different places he had, and he
went up to one set of six and said to them, “Here is a helper I am
bringing you; I don’t think he’ll increase our work, and I myself will
give him enough to eat.”
They spat upon him and said they would not have him.
Then they came to another six, and they would not take him; and
they came to another, and they took him. And when the master
went away, Crooked-mouth said he was sleepy, and asked for leave
to sleep that day. And they gave him leave; and in the night he told
them not to go out to work in the morning until he came in to his
breakfast, and when he came in to his breakfast the work of a week
was done. And those six were walking about and not doing a turn.
At that time a gentleman sent an invitation to dinner to the man
(who had the workmen) and for his men to come with him. And they
went drawing that way, and a robber met them on the road and
bound every one of them and took his money from the master. And
he told his men to bind Crooked-mouth, and Crooked-mouth said
that not one should bind him but the robber himself.
“Come up to me and I’ll bind you. You won’t be having your
stories to make of me.”
When he went to bind him, Crooked-mouth laid hold of him, and
turned him round, and threw him on the ground, and told him to
hand out his master’s money quickly, or he would kill him. So he
gave him the money back and loosed the men.
“Master,” said he, “here are twelve others for him, and I will do
their work.”
“Oh!” said the master, “I will not ask one turn of you, except one
meal and one drink for ever.”
So he gave over to the robber the twelve other men, who had
refused to let him work with them. And before he parted with the
robber he put him under obligations.
“I will not kill you,” said he, “this is O’Daly, and I am Gerald O’Daly,
and anything at all that’s ever asked of you by the honour of O’Daly,
do that.”
Then they went on with themselves to the house, and there was a
feast ready for them; and they took their meal, and while they were
eating, the twelve others he gave over to the robber came. One of
them asked the robber to let them go their way by the honour of
O’Daly, and he told them to go and a hundred welcomes, and if it
were a greater thing (he would grant it).
When Crooked-mouth ate his supper, he stretched himself under
the table, and when the others ate their supper, (the gentleman) put
them out to sleep in the barn, and when he came in he heard
snoring, and he gave the man a kick, and asked him why he wasn’t
with the others, and he said he would not leave the house that
night; and the man of the house said that he must leave; that no
one slept in the house for a year, and that he should not sleep in it
that night. But the other said he would sleep in it, and find out about
everything in the house. He took the man of the house and put him
in a basket, and put him in the chimney to smother him; and he
asked him, “Let me down, and I will tell you.” He let him down, but
he would not tell him; and he put him back three times one after
another, and the third time he came down he told him.
“I was one day standing at the gable of my house, and I saw a
ship coming under full sail into the harbour, and a man and a woman
jumped out (on the shore) and ran; and I saw a great monster in
the sea coming the same way, and the monster ran after them; and
the man put his hand in his pocket, and pulled out something, and
flung it at the monster; and the monster sent out such a spout of
blood that the two were drowned in it. I took them with me and
washed them, and I put herbs of the hill on them, and I have had
them for two years, and there is not a night since that I don’t burn a
penny candle looking at their beauty.”
He opened a room and showed them to Crooked-mouth, and he
took the water of healing and sprinkled some of it on them, and they
arose alive again. And his mouth came as it was at first, and the
disfigurement went from him, and he asked his brother what it was
took him that way. And his brother said,—
“When you were gone a day and a year I went to the sea, hoping
to see a ship or boat that would give me tidings of you, or to see if I
would see a board that I would recognise; and one day I met a
pretty bird-serpent, and a stone with him, and it was written on the
stone that that was the stone that would kill the bird; and I took the
stone and the bird home with me, and I put the bird into a cage,
and kept it there for a week, and it became so big I had to put it
into the stable; and it went on growing bigger and bigger till I had to
make a place for it in the wood, and to tie the brambles round it,
and I had four men killing beef and giving it food. And one day I was
walking round near it, and it made a lunge at me to eat me, and I
said it would do that at last. I went and took a ship, and went to
sea, and I was sailing three days when my sister rose up to me, and
I did not know she was on board the ship. We were sailing till we
came to the harbour, and the serpent was following us, and I went
up on the land, and the serpent followed; and, as God was helping
me, I had my waistcoat on that day, and the stone was in the
pocket, and I flung the stone at her, and she spouted so much blood
that I and my sister were drowned. I don’t know what happened to
us since then.”
“I took you with me, and cleansed you, and put herbs of the hill
round about you, and there is not a night for two years I don’t burn
a penny candle looking on you, and I believe that it is I should get
her in marriage.”
The four spent the night pleasantly, telling one another
everything; and in the morning when they arose, and the people
who were at supper the night before were gathered together, the
master did not recognise that Crooked-mouth was with him. But
when Crooked-mouth told him that it was he was there, O’Daly bade
him come with him, but he would not. He went with his brother and
his sister and the other man to Scotland. And when they came to his
father’s court, his father was banished by Faugauns and Blue-men;
and he and the other people who were taking possession of his
father’s court began; and he and they spent three nights and three
days killing one another, and on the third day he had killed and
banished them all. But when he and the cat met, the cat killed him
and he killed the cat; and his brother was going everywhere that he
killed, and at last he found him and the cat dead. And he searched
his pocket and found in it the bottle of healing-water, and as he was
drawing the cork from the bottle, some of the water fell on the dead
man, and he arose alive again.
He went then with his sister and the other man who was in the
place of husband to his sister; and they cleansed the king’s castle,
and he brought his father and mother and their people home to the
castle, and they were well from that out. Then he gave his sister in
marriage to the man, who found himself and her on the day when
the serpent drowned them. There came the priest of the pattens and
the clerk of the table, and the pair were wedded.
He himself then went back to Erin, and married the daughter of
the King of Erin, who was to be eaten by the giants, and the son of
the King of Prussia was to save her.
[12] This contradicts what is stated on page 140.
BEAUTY OF THE WORLD.
Narrator, P. Minahan, Malinmore, Glencolumkille, co. Donegal.
There was a king then, and he had but one son. He was out
hunting. He was going past the churchyard. There were four men in
the churchyard and a corpse. There was debt on the corpse. The
king’s son went in. He asked what was the matter. Said one of the
men:
“The dead man is in our debt. I am not willing to bury the body,
till the two sons who are here, promise to pay the debts.”
“We are not able to pay,” said one of them.
“I have five pounds,” said the king’s son; “I will give them to you
to bury the body.”
He gave the five pounds. The body was buried. The king’s son
went hunting. He went home in the evening. In the morning of the
morrow there was snow. He went out hunting in the snow. He killed
a black raven. He stood over it and looked at it. He said in his own
mind he would never marry a woman whose head was not as black
as the bird’s wing, and her skin as white as the snow, and her
cheeks as red as the blood on the snow.
He went home. On the morning of the morrow, when he rose, he
washed himself, and he went away to find the woman. When he was
going for a time, he met with a red-haired young man. The young
man saluted him. He asked him where he was going. The king’s son
told him he was going to get one sight of that woman.
“It is better for you to hire me,” said the young man.
“What wages do you be asking?”
“Half of all we gain, to the end of a year and a day.”
The two went on with themselves till the evening came. Said the
red man:
“There is a man related to me living in this wood below. Do you
wait here till I go down to him.”
The red man went down to the house of the giant. The giant was
sitting on a chair by the fire.
“Uncle, dear,” said the red man, “is it like this you are?”
“Yes, kinsman mine: what is coming to me?”
Said the red man: “The King of the prodigious Eastern World is
coming up to kill you. Get out of the way as quick as you can.”
“I have an iron house outside there. Lock me into it.”
He locked the man in. He went to his master. He took his master
up to the house of the giant. He got ready their supper. They went
to rest. This was the giant’s cry in the morning. “Let them open.”
The red man went to him. He asked him what was the matter.
“I am ready to perish with hunger. Let me out of this quickly.”
“I will not let you out,” said the red man, “till you tell me where
the dark cloak is.”
“That is what I will never tell any one.”
“Well, if you like better not to tell, you will be there till you die.”
“Sooner than be here any longer, it is hanging in such a room.”
“I know where it is,” said the red man. “Be here as long as you
like.”
When the giant heard that he would not get out, he took a jump
out between two bars of the iron house. Two halves were made of
him. Half fell outside and half inside. The red man went to the
giant’s house. He got ready the breakfast. He and his master
breakfasted. He took with them plenty of gold and silver, two horses
and two saddles. They went till evening was there, and they went
into another wood.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebooknice.com

More Related Content

PDF
(Ebook) Practical Web Development by kan
PDF
Practical Web Development 1st Edition Wellens Paul 2024 scribd download
PDF
Practical Web Development 1st Edition Wellens Paul
KEY
Approaches to mobile site development
PDF
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
PPT
Advanced Web Development
PPT
Cms an overview
PDF
Intro to mobile web application development
(Ebook) Practical Web Development by kan
Practical Web Development 1st Edition Wellens Paul 2024 scribd download
Practical Web Development 1st Edition Wellens Paul
Approaches to mobile site development
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
Advanced Web Development
Cms an overview
Intro to mobile web application development

Similar to (Ebook) Practical Web Development by kan (20)

ODP
Drupal Theme Development - DrupalCon Chicago 2011
PPT
Dojo - from web page to web apps
PDF
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
PDF
Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Interac...
PDF
CCCDjango2010.pdf
PPTX
SharePoint Framework SPS Madrid 2016
ODP
Web 2.0
PDF
Get Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Int...
PPT
Intro to-html-backbone
PPT
SharePoint Developer Education Day Palo Alto
PDF
DIPLOMA IN DESIGNING AND WEBSITE DEVELOPMENT
PDF
What book and journal publishers need to know to get accessibility right
PDF
Best training institute
PDF
Training institute in Bangalore
PPT
Scaling 101
PPT
Scaling 101 test
PDF
Full download Responsive Web Design with HTML5 and CSS3 Second Edition Ben Fr...
PDF
Develop Engaging and High Performance Portal Themes That Power Exceptional Di...
PPTX
Web application architecture
PPT
Websites Unlimited - Pay Monthly Websites
Drupal Theme Development - DrupalCon Chicago 2011
Dojo - from web page to web apps
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Interac...
CCCDjango2010.pdf
SharePoint Framework SPS Madrid 2016
Web 2.0
Get Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Int...
Intro to-html-backbone
SharePoint Developer Education Day Palo Alto
DIPLOMA IN DESIGNING AND WEBSITE DEVELOPMENT
What book and journal publishers need to know to get accessibility right
Best training institute
Training institute in Bangalore
Scaling 101
Scaling 101 test
Full download Responsive Web Design with HTML5 and CSS3 Second Edition Ben Fr...
Develop Engaging and High Performance Portal Themes That Power Exceptional Di...
Web application architecture
Websites Unlimited - Pay Monthly Websites
Ad

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Institutional Correction lecture only . . .
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Insiders guide to clinical Medicine.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharma ospi slides which help in ospi learning
PDF
Complications of Minimal Access Surgery at WLH
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Cell Structure & Organelles in detailed.
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
VCE English Exam - Section C Student Revision Booklet
Week 4 Term 3 Study Techniques revisited.pptx
human mycosis Human fungal infections are called human mycosis..pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Institutional Correction lecture only . . .
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Insiders guide to clinical Medicine.pdf
RMMM.pdf make it easy to upload and study
Pharma ospi slides which help in ospi learning
Complications of Minimal Access Surgery at WLH
STATICS OF THE RIGID BODIES Hibbelers.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Ad

(Ebook) Practical Web Development by kan

  • 1. Instant Ebook Access, One Click Away – Begin at ebooknice.com (Ebook) Practical Web Development by kan https://ebooknice.com/product/practical-web- development-50195080 OR CLICK BUTTON DOWLOAD EBOOK Get Instant Ebook Downloads – Browse at https://ebooknice.com
  • 2. Instant digital products (PDF, ePub, MOBI) ready for you Download now and discover formats that fit your needs... Start reading on any device today! (Ebook) Learning Django Web Development_ From idea to prototype, a learner's guide for web development with the Django application framework by kan https://ebooknice.com/product/learning-django-web-development-from-idea-to- prototype-a-learner-s-guide-for-web-development-with-the-django-application- framework-50195350 ebooknice.com (Ebook) The Complete Web Design Edition by kan https://ebooknice.com/product/the-complete-web-design-edition-50194588 ebooknice.com (Ebook) Practical Electronics for Inventors by kan https://ebooknice.com/product/practical-electronics-for-inventors-50195098 ebooknice.com (Ebook) JavaScript Cookbook, 2nd Edition_ Programming the Web by kan https://ebooknice.com/product/javascript-cookbook-2nd-edition-programming-the- web-50195402 ebooknice.com
  • 3. (Ebook) Learning LibGDX Game Development, 2nd Edition by kan https://ebooknice.com/product/learning-libgdx-game-development-2nd- edition-50195342 ebooknice.com (Ebook) Python, PyGame and Raspberry Pi Game Development by kan https://ebooknice.com/product/python-pygame-and-raspberry-pi-game- development-50196044 ebooknice.com (Ebook) Complete Vue.js 2 Web Development: Practical guide to building end-to-end web development solutions with Vue.js 2 by Mike Street, Andrea Passaglia, Paul Halliday ISBN 9781789959901, 178995990X https://ebooknice.com/product/complete-vue-js-2-web-development-practical-guide- to-building-end-to-end-web-development-solutions-with-vue-js-2-7336226 ebooknice.com (Ebook) HTML5 Game Development by Example: Beginner's Guide by kan https://ebooknice.com/product/html5-game-development-by-example-beginner-s- guide-50195518 ebooknice.com (Ebook) Practical Webix: Learn to Expedite and Improve your Web Development by Frank Zammetti ISBN 9781484233832, 1484233832 https://ebooknice.com/product/practical-webix-learn-to-expedite-and-improve- your-web-development-6981952 ebooknice.com
  • 7. Table of Contents Practical Web Development Credits About the Author Acknowledgments About the Reviewers www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions 1. The World Wide Web World Wide Web The Internet HTTP and HTML HTML HTTP The World Wide Web Consortium (W3C) Mosaic The first browser Netscape Internet Explorer The explosion of the Web Amazon.com and e-commerce Google and Yahoo! Social networking
  • 8. Web development HTML HTML editors and other tools Browsers and web servers CSS JavaScript PHP Data Summary 2. HTML HTML versions Semantic and presentational HTML The structure and syntax of an HTML document Doctype <html> <head> <body> Syntax for tags or elements inside the document HTML comments Links The <a> tag and attributes The href attribute The <a> name attribute The <a> target attribute Classic document elements <h1>, <h2>, <h3>, … <h6> – headings <p> – paragraph <span> – span Lists Images <img> element and attributes Image width and height Input forms Form elements Form attributes The label attribute Input attributes The name attribute The value attribute
  • 9. The checked attribute The readonly attribute Textarea Dropdown lists The disabled attribute The selected attribute Tables Table elements <table> <thead> <tbody> <tr> <th> <td> Table attributes colspan (td) rowspan (td) <div>, the "uebertag" HTML entities HTML5-specific tags Summary 3. CSS Adding styles to our documents External style sheets Internal CSS Inline styles The Document Object Model (DOM) Selectors Multiple classes Descendants Selecting children or siblings Specificity Block elements and inline elements Colors Fonts So what are fonts? Font families Serif fonts Sans-serif fonts Monospace fonts The font-family property
  • 10. Font-weight and font-style Font-size Line-height The box model Padding Border Margin Collapsing margins Positioning Float position:relative position:absolute Styling lists list-style-type list-style-image list-style-position Styling anchors – pseudo-classes Firebug Summary 4. JavaScript Programming 101 Compiled and interpreted languages compared JavaScript is not the same as Java Java JavaScript Our first JavaScript program Variables Variable declarations Values of variables Numbers Strings Converting strings to numbers Expressions and operators Arithmetic operators Addition(+) Subtraction (-) Multiplication (*) Division (/) Modulo (%)
  • 11. Relational operators Control flow if while switch Functions Scope of variables Objects JSON DOM objects, properties, methods, and events The Window object The Document object write and writeln methods Nodes and DOM traversing Events Summary 5. PHP Introduction to PHP Our first real PHP program PHP and web hosting Web hosting 101 Domain name Web hosting companies Server-side setup Additional server-side services PHP development environment PHP as a web development language Variables, values, operators, and expressions Scope of variables Local variables Global variables Static variables String operators To double quote or to single quote, that is the question Control flow Functions String functions strpos() strlen()
  • 12. substr() Date functions time() date() strtotime() Arrays Numeric arrays or indexed arrays Associative arrays Cool control statements for associative arrays Sending data back to the server – forms POST or GET, what should we get? $_POST and $_GET arrays Files include, require, and require_once Regular files File functions or f-functions fopen file_exists(), is_file(), and is_dir() fread and fwrite One line at a time – fgets() The printf family Syntax of printf family of functions Summary 6. PHP and MySQL Databases Relational databases SQL MySQL phpMyAdmin Creating databases Creating and managing users Creating and managing database tables MySQLi in PHP Connecting to the database Our first SQL query, really! Writing a MySQL query in PHP Fetching the result Obtaining data from more than one table Adding data
  • 13. Updating data Summary 7. jQuery Obtaining the jQuery library Where to place the jQuery library on your page? jQuery UI and jQuery Mobile Using jQuery selectors and methods html() text() attr() .val() show() and hide() .find() .parent() .next() .css() jQuery documentation Event handlers and jQuery preventDefault() $(this) updateNewsContent() Summary 8. Ajax XMLHttpRequest Ajax and jQuery jQuery Ajax methods $.load() method $.post() $.ajax() Summary 9. The History API – Not Forgetting Where We Are The problem we are trying to solve The self-service restaurant HTML5 History API and the history object pushState() popstate event popstate and different browsers The History plugin Bookmarking
  • 14. Summary 10. XML and JSON XML XML format Displaying XML files XML editors XML Schema SimpleXML The XML file The XML Schema file The CSS file The PHP file Creating XML files with SimpleXML Generating our HTML on the client side XSLT JSON JSON syntax JSON values JSON objects JSON strings JSON arrays JSON numbers JSON and PHP JSON with Ajax and jQuery Two useful JSON methods Summary 11. MongoDB Relational database management systems NoSQL databases MongoDB Installing MongoDB The MongoDB shell Creating databases, collections, and documents _id and ObjectIds Loading scripts Removing documents Updating documents MongoDB data types Basic data types
  • 15. Dates Embedded documents One more example MongoDB and PHP Getting our gallery data CRUD operations with MongoDB and PHP Insert documents Update documents Queries with conditions MongoDB cursor object Summary 12. Mobile First, Responsive Design with Progressive Enhancement Responsive design Déjà vu Media queries Using the media attribute Do more with less Mobile first Why mobile first? We have come a long way Mobile devices have newer capabilities Mobile devices are not only used while on the road Content first, navigation next Small means big Mobile input Mobile first recap Progressive enhancement EnhanceJS enhance.js loadStyles and loadScripts enhanced and FOUC Modernizr The Modernizr object Polyfills and Modernizr yepnope.js or Modernizr.load Summary 13. Foundation – A Responsive CSS/JavaScript Framework Our responsive toolkit – Foundation Foundation components
  • 16. The grid system Class end Visibility classes The block grid system Useful UI elements Thumbnails – for simple galleries Reveal modals – your better pop-up Dropdowns Example – a simple photo gallery Accordions Awesome Font awesome Equalizer – the hardest thing to do with two <div>s made easy Navigation Top bar – not just your regular menu bar Adding more magic Yet more magic – off-canvas, the coolest thing Summary 14. Node.js Node.js Installing node.js npm node Adding HTML Serving up static content A tale of two (JavaScript) cities node.js and MongoDB Déjà vu … once more Express Installing Express Our first Express app An example with middleware Templating and handlebars.js Creating a layout Our last Hello, World example Summary A. Bootstrap – An Alternative to Foundation Bootstrap components The Bootstrap grid system Visibility classes
  • 17. Buttons Other UI elements Thumbnails Dropdowns Modal – the Bootstrap popup Combining dropdowns and modals Collapse – an accordion for Bootstrap Navigation Summary Index
  • 19. Practical Web Development Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: July 2015 Production reference: 1240715 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78217-591-9 www.packtpub.com
  • 20. Credits Author Paul Wellens Reviewers Jorge Albaladejo Elvis Boansi Adam Maus Jesús Pérez Paz Commissioning Editor Edward Gordon Acquisition Editors James Jones Sonali Vernekar Content Development Editor Ritika Singh Technical Editor Ryan Kochery Copy Editors Alpha Singh Ameesha Green Jasmine Nadar
  • 21. Jasmine Nadar Project Coordinator Milton Dsouza Proofreader Safis Editing Indexer Rekha Nair Production Coordinator Manu Joseph Cover Work Manu Joseph
  • 22. About the Author Paul Wellens has been a senior product manager for a major computer company in the Los Angeles area and Silicon Valley for over two decades. Before that, he used to install Unix systems and train companies in Europe, from his native Belgium. Later in his career, he became a web development aficionado because it brought him back to another passion of his: programming. This is not his first book. His prior publication is of a different nature. Nature is what it is all about as it is a guidebook on Eastern California, which is illustrated with his own photographs. Therefore, it should not come as a surprise to learn that, besides experimenting with new web technologies, his major hobbies are photography and hiking in the Eastern Sierra.
  • 23. Acknowledgments I have written books before and I know that the result can only be successful if there are some nice people to assist you. This is the first time that I have worked with a publisher, Packt Publishing, so these are the first people I would like to thank. I would like to thank Shivani Wala for discovering me and James Jones for working with me to figure out the right book for me to write and for you to read. I enjoyed working with Priyanka Shah, Ritika Singh, and Ryan Kochery who assisted me in bringing this cool project to completion, without a single complaint, even though I was once again late with a deliverable. Thank you for being so patient with me. I would also like to thank (yes, this is a note of cynicism) the three companies that "manage" the railroads in Belgium. Without their comedy of errors with trains—delays, cancellations, failure to depart because of mechanical problems, or trains departing from the station where you want to get to, as opposed to depart from, I would never had so much time to work on this book on my iPad. It is not in their honor, but, because for 2 years, it was the highlight of my day to safely arrive at Antwerp Central Station—which was rated by an American newspaper as the most beautiful train station in the world—that we decided to use it as the cover photo. Next, I would like to thank my web developer buddy, Björn Beheydt, for taking the time to read the early versions of the chapters of this book and providing constructive feedback. I would also like to mention Steve Drach and Bart Reunes for always being there when I needed some technical advice. Then, there are places that I would like to call a home away from home, where folks did not mind that I was typing away on my Bluetooth keyboard when inspiration kicked in. Most notably, I have to thank the folks at Trapke Op (Caro, Maressa, Evi, Klaartje and Jill) in Brecht, Belgium, where I typed these sentences. These wonderful people helped me make it to the finish line. Het Boshuisje in Zoersel, where Hendrik Conscience wrote books over a hundred years before I did, also comes to mind. I would like to thank Theo for always giving me a seat to land with my iPad, keyboard, and work. Less related to this book, but still in need of a mention, are all my friends in California that inspired me to carry on doing great things in hard times. In particular, I want to express my appreciation to the people that work(ed) at the
  • 24. particular, I want to express my appreciation to the people that work(ed) at the Gordon Biersch Restaurant in Palo Alto, which I can still proudly call my photo gallery. I thank them for their support for over 11 years and for still welcoming me when I visit them; they make me feel as if I only left last night. That also includes the patrons of the place with whom I've had numerous conversations and enjoyed every single one of them. If you read this book, or my previous book, you will notice that I have a certain affinity and passion for a particular part of California. So, I would like to thank all the wonderful folks that live in the town of June Lake, California, for always having inspired me to come back and be creative. My goal in life is to go there as often as I can. Finally, I would like to thank my mother. It has been hard for her since my father passed away and her son returned. I am dedicating this book to her, not that I expect her to read it, but I really appreciate the patience she had with me while I was writing it.
  • 25. About the Reviewers Jorge Albaladejo is a software engineer with a master's degree in information and communication technologies from HES-SO, Switzerland. With over a decade of experience building cloud, SaaS, and web applications, he considers himself to be a passionate and versatile full-stack web developer. Throughout his professional experience, he has worked with many companies in different fields, such as project management, social networks, quality assurance, weather data visualization, and video games. He devours countless books about software engineering, project management, and science fiction, and he is passionate about clean, long-lasting software architectures. He is currently working as a freelance contractor under the commercial name of CometaStudio, and he is mostly interested in start-ups and mid-sized companies that build great web experiences for great causes that make a difference. His next dream is to become a digital nomad who travels around the globe while working at the same time—and learn languages in the process! Elvis Boansi is a software developer at John Jay College. He develops and maintains custom web applications that are used by members of the college. In his spare time, he enjoys playing soccer and basketball with his friends. I'd like to thank my employers at John Jay College for all of their support. I would also like to thank my supervisors, Ana and Juan, for their feedback. I thank my friends, Sanga, Steve, and Loric, for constantly sharing their knowledge with me. Adam Maus is a software developer with a master's degree in computer science and works at the Center for Health Enhancement Systems Studies at the University of Wisconsin in Madison in the United States. His interests lie in developing web technologies that utilize data mining to create better user experiences. He primarily works on websites that help people undergoing addiction recovery support, as well as people who are aging. In his free time, he enjoys running, biking, and reading books. Jesús Pérez Paz is a full-stack web developer with experience in project
  • 26. management. He works at PepitaStore Inc. and collaborates with Mozilla. His main area of work is design, and he integrates the user interface (or frontend) of web pages / applications; however, lately, he has been diving into backend stuff and has become a full-stack web developer. He loves the open/free Internet and thinks that the Internet is a global public resource that must remain open and accessible to everyone.
  • 27. www.PacktPub.com Support files, eBooks, discount offers, and more For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <service@packtpub.com> for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
  • 28. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser
  • 29. Free access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
  • 30. Preface I am fortunate to have lived and worked in California for a long time. The majority of that time, I lived in Palo Alto, which is the center of Silicon Valley, the home of Stanford University, and the birthplace of many companies, big and small, such as Sun Microsystems, where I worked. I sat on the front row to see how the World Wide Web developed, as well as being present for the advent of social media. Facebook started on the other side of the wall of my favorite restaurant. Now, some Facebook guy or girl is sitting in what used to be my office at the bottom of the Dumbarton Bridge. As a product manager for Solaris, one of my tasks was to make sure that Netscape Navigator was included with our operating system. So, I was right at the source in which the development of the Web began. I even went to the Web 2.0 conference and bought the book of the same name. Then, I felt the need to have my own website to display my photographs and inform people about the beauty and interesting places of the parts of California that I had discovered during my many journeys travelling around the state. So, I created one. One day, I was telling a friend about it and he tried to look at it on his mobile phone. It looked terrible. So, I bought a Nokia phone (a brick compared to what we have today) so that I could test my own site to make sure that it looked good on a phone as well. This is how I caught the bug of responsive design, years before someone started calling it this. Upon my return to Belgium, I decided that it was time to learn as much as possible (I love to learn new things) about what is out there beyond creating websites and took a 6-month course on PHP web development. A lot of it looked familiar as I was previously a UNIX and C developer. There were only 12 people in the class, who were all bright minds, and I quickly discovered that there was more to learn. As the classes took place in Leuven, a major university town in Belgium, I went to the local university bookstore and bought book after book on all kinds of related topics and quickly became a jQuery fan. jQuery, by the way, was not even included in the course. I started wondering why someone needed to have 35 different books to learn about web development and that writing a single book that gave a comprehensive overview of what you need to know to engage in web development would not be a bad idea.
  • 31. Since then, web development has changed a lot; more books were needed, eBooks this time, but the concept remained the same. So, now you know why I wrote the book. This book gives you an overview of all the general aspects of web development, in a traditional way, using plain HTML to do static websites, as well as the current way, to enable you to create your web pages dynamically and make sure that they look great on mobile devices as well, by using responsive design. We conclude by giving you a hint of what is yet to come if you replace the traditional web server by writing your own using node.js.
  • 32. What this book covers Chapter 1, The World Wide Web, gives you an overview of the history of what we know today as the World Wide Web. Chapter 2, HTML, introduces HTML and gives you an overview of the most commonly used HTML tags to do web development. You will be able to create a basic website after reading this chapter. Chapter 3, CSS, explains how to use Cascading Style Sheets (CSS). This is used for the presentation part or layout of your website, from color to dimensions to typefaces. The most commonly used CSS properties are explained here. Once you are done with this chapter, you will be able to make your basic website look good. Chapter 4, JavaScript, first gives you an introduction to the world of programming and programming languages. Next, the overall syntax of JavaScript and how to use it for client-side programming is introduced. Chapter 5, PHP, explains PHP, which is another programming language. This one is used to do server-side programming. It requires a web server to do the development of your website and deploy it. You will learn how to dynamically create your web pages, rather than having to write a bunch of HTML files. Chapter 6, PHP and MySQL, introduces MySQL, an open source database. You will learn how to create a database, manage it using the phpMyAdmin tool, and perform basic CRUD (create, replace, update, delete) operations from within a PHP program. Chapter 7, jQuery, covers a popular JavaScript library. It allows you to write more compact and clean code and handles browser incompatibilities for you. With this, it is going to be a lot easier and faster for you to write JavaScript code that traverses and manipulates the web page. It does so by using selectors, which you learned to use with CSS. So, with jQuery, you can write JavaScript code without having to learn a lot of JavaScript. Chapter 8, Ajax, introduces Ajax. It represents a collection of techniques to make it easy to dynamically change only portions of a website. With this chapter, we have entered the world of what I call "modern web development". The interface
  • 33. that we use for our Ajax calls is jQuery. Chapter 9, The History API—Not Forgetting Where We Are, explains a very important piece of the web development puzzle. Once we are changing pages on the fly so they look different but actually remain the same page (URL), strange things can happen when visitors want to go back to what they think is the previous page. A solution for this is described here that will not only work for HTML5 but for HTML4 as well. Chapter 10, XML and JSON, describes XML and JSON. They are two popular formats to exchange data, for example the server and the client. Although XML is used in a variety of environments, JSON is closer to the web development community. Chapter 11, MongoDB, describes an alternative to MySQL as a database. This is a so-called NoSQL database and a document database. Documents are conveniently in the JSON format. Here, how to access a MongoDB database from within a PHP program is described. Chapter 12, Mobile First, Responsive Design with Progressive Enhancement, has the longest chapter title of the book. It explains how modern web development has to be done now that more people are using mobile devices instead of traditional computer screens to go to websites. Chapter 13, Foundation – A Responsive CSS/JavaScript Framework, describes most of the features of the Foundation framework, which helps you with your responsive design. It contains everything that I have always wanted to write myself but never had the time to do. This concludes the part of the book that covers what I call modern web development. Chapter 14, Node.js, gives an overview of what I call the avant-garde of web development. It introduces node.js, which allows you to write your server-side code in JavaScript, including your own web server, which is facilitated by using the Express framework. Appendix, Bootstrap – An Alternative to Foundation, describes the popular CSS/JavaScript framework, which is an alternative to Foundation to help you with responsive design. The main reason to include this is to point out key differences and similarities.
  • 34. The online chapter, The Mono County Site, provides a full example of a website or application where we apply most, if not all, the things we learned. It is available at https://www.packtpub.com/sites/default/files/downloads/B03816_Appendix.pdf.
  • 35. What you need for this book You will need the following software to work with the examples in this book: Software Source Firefox and Firebug http://www.mozilla.org Apache Web Server Part of the OS XAMPP (includes MySQL and PHPMyAdmin) http://www.apachefriends.org MySQL http://www.mysql.com PHPMyAdmin phpmyadmin.net jQuery http://www.jquery.com The History jQuery plugin https://github.com/browserstate/history.js MongoDB mongodb.org Foundation foundation.zurb.com Node.js nodejs.org Bootstrap getbootstrap.com
  • 36. Who this book is for This book is for anyone who wants to get to grips with the broader picture of web development today. It is perfect for beginners who want to get started and learn web development basics, such as HTML, but it also offers experienced developers a web development road map that will help them to extend their capabilities and gain a greater insight into how different technologies interact and work together.
  • 37. Conventions In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive." A block of code is set as follows: <body> <div id="header"></div> <div id="container"> <div id="left"></div><div id="middle"></div><div id="right"></div> </div> <div id="footer"></div> </body> When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: <tag class="value1 value2">text<?tag> Any command-line input or output is written as follows: { "key" : { "name":"Schwarzenegger","first":"Arnold", "profession":"governator" } } New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: " Now, not until a user clicks the Beach button, Hello, World will turn into Hello, Beach." Note Warnings or important notes appear in a box like this. Tip Tips and tricks appear like this.
  • 38. Tips and tricks appear like this.
  • 39. Reader feedback Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
  • 40. Customer support Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
  • 41. Downloading the example code You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files emailed directly to you.
  • 42. Errata Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
  • 43. Piracy Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.
  • 44. Questions If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.
  • 45. Chapter 1. The World Wide Web This book talks about the past, present, and future of Web Development. Beginning with Chapter 2, HTML, we will walk you through all the technologies you need to know about, in order to practice web development. Before we do that, we want to set the stage, so that we all know which Web we are talking about: this would be the World Wide Web (www).
  • 46. World Wide Web I love history! So let us start with a little history about the World Wide Web. I was fortunate enough to be able to work at a company that developed the first commercial version of the UNIX Operating System. They were founded in 1977 and I joined them ten years later. UNIX is an Operating System (the thing you need to make your computer do something) that was intended to run on minicomputers (although they were called that, they could not fit into your apartment and required air-cooling). These computers were typically used as an isolated system that had quite a number of text-based terminals attached to them. Today UNIX lives on, and forms the basis of Linux, Solaris, MacOS, and others. Our company spotted an opportunity to add products that would add features and technologies that today are standard. Some of these examples are email (ability to send a mail to a person on another computer), and ftp (ability to transfer a file to another computer, or to just access another computer). Yes, you had to pay extra if you wanted to be able to send mail. Thanks to the Internet, all of this was made possible.
  • 47. The Internet The Internet is a global network that today interconnects billions of computers worldwide. Its origin dates back to research done for the US government, but today everybody can get on the Internet, using its standard set of protocols, commonly referred to as TCP/IP (the IP here being Internet Protocol). Every computer or device that is connected to the Internet will have a unique Internet address, aka IP address. It is a set of 4 numbers separated by dots, for example, 192.25.13.90. Of course, you will never tell your friend that you bought something at 192.25.13.90 but at, for instance, www.amazon.com. This is because the Internet also uses a feature that translates IP addresses into easier to remember domain names. The example I used happens to be a website you can go to and buy things from a practice that we all know has caused the www to become what it is today. The Internet and the www are, in everyday speech, treated as if they are synonyms but they are indeed not. There are a lot of different services provided on the Internet (by companies called Internet Service Providers (ISP)), and that was already the case before the www existed (for example, giving you access to electronic mail). What it took for the www to emerge was (just like in JavaScript) a series of asynchronous events. Two of those are too important to not mention.
  • 48. HTTP and HTML You have probably heard this story many times, but the World Wide Web would not have existed without it. It is the story of Tim Berners Lee, an engineer at the European Centre for Nuclear Research (CERN). The centre had many computers that were, of course, hooked up to the Internet. It also produced a tremendous amount of data and documents, and that became almost impossible to manage. Tim worked out a solution by developing a language to write these documents in, a protocol on top of the Internet to manage them, as well as a computer program for users to access them.
  • 49. HTML HTML, short for Hypertext Markup Language is the name of that language. Hypertext is text that contains hyperlinks, which in turn are those parts of a document which readers can click on to take them to a different document, using the link. You have all seen the blue underlined parts of a text, in not-so-good- looking web pages. These are hyperlinks. A document in HTML consists of tags, with text in between them. There are opening and closing tags for example, as follows: <h1>Hello, world</h1> Here, <h1> is the opening tag and </h1> the closing one. We will learn about a similar markup language: XML. HTML and XML are not the same though. One important difference is that in XML you can define your own tags, as long as you close each one you've opened. XML is used to transfer the data and the tags are used to organize the data. In HTML, tags do have a specific meaning. <h1> would be used in a document for the text of a level one header. A <a> tag—the anchor tag—is the one used to include the hyperlinks we just discussed. So the purpose of writing HTML is not to transfer data, but to present it to human users. To do so, these tags are interpreted by the computer program we mentioned earlier. Such a program is called a browser. When the reader clicks on a hyperlink, the browser will detect that as well, and send a request to yet another program, the web server, to go fetch another document.
  • 50. Other documents randomly have different content
  • 51. The tailor went and bought a suit of clothes for him. She put them on him. He and the tailor went to the shop. “Here’s a young man I have got for you,” said she. He hired the young man for a year. The young man came to him and was serving him well. Better was the learning that he had than the shopman’s. The tailor was content as they were together. They were the two comrades; nor did he ever recognise the tailor. They were a couple of years in the city. One day the tailor said they were there long enough, and would go home for a while now. He said he would never go home. She said she would, that they would get a place as good as to be there. They got ready and were drawing towards Dublin. The clerk said he would not go near the city. She said she would go. They walked on till they came to the city. There was no going through the street for the clerk. He became sorrowful and troubled. They were walking till they came to the house they used to live in. “This is a good house,” said the tailor; “we’ll go in to see if they will keep us for the night.” “We will not go into that house on any account.” “We’ll go to no other place but that,” said the tailor. They went in and got place till morning. The captain was living there always. There were gentlemen dining with him. The tailor was making fun for the girls in the kitchen. He began dancing and singing. The clerk was sitting under the window, with his head bent down. When the gentlemen heard the singing and the dancing in the kitchen, they opened the parlour door to see the tailor playing his music. They bade him come up to the parlour, to themselves. He said he would like to have his companion with him. They bade the two come. The two went up. They got whiskey. They made the tailor sing. He was performing a while. He looked about him. “This is a fine house you have,” said he. “I have travelled far enough, but I never in my travellings met with a better house than this of yours.”
  • 52. “Simply I got this house.” He told the gentlemen how he came into the house. “Well,” said the tailor, “you bear witness to everything you have heard. I was the woman, that was in the house, to whom that happened.” She opened her bosom to show it was a woman. “Get up, you gillie over there.” She locked the parlour door. Kayleh went for the police. The police came. They arrested the captain. The gentlemen were witnesses. The captain was put in prison. She put off the tailor’s clothes then. They arrested the maid and put her in prison. They fell into their house and place again. They were then as they were ever. The report went out through the city that Kayleh and the king’s daughter were in their own house again. The king then made a dinner and invited them to it. They were eating and drinking for three nights and three days. [10] Or “Spouse of Poverty.”
  • 53. SIMON AND MARGARET. Narrator, Michael Faherty, Renvyle, co. Galway. Long ago there was a king’s son called Simon, and he came in a ship from the east to Eire. In the place where he came to harbour he met with a woman whose name was Margaret, and she fell in love with him. And she asked him if he would take her with him in the ship. He said he would not take her, that he had no business with her, “for I am married already,” said he. But the day he was going to sea she followed him to the ship, and such a beautiful woman was she that he said to himself that he would not put her out of the ship; “but before I go farther I must get beef.” He returned back and got the beef. He took the woman and the beef in the ship, and he ordered the sailors to make everything ready that they might be sailing on the sea. They were not long from land when they saw a great bulk making towards them, and it seemed to them it was more like a serpent than anything else whatever. And it was not long till the serpent cried out, “Throw me the Irish person you have on board.” “We have no Irish person in the ship,” said the king’s son, “for it is foreign people we are; but we have meat we took from Eire, and, if you wish, we will give you that.” “Give it to me,” said the serpent, “and everything else you took from Eire.” He threw out a quarter of the beef, and the serpent went away that day, and on the morrow morning she came again, and they threw out another quarter, and one every day till the meat was gone. And the next day the serpent came again and she cried out to the king’s son, “Throw the Irish flesh out to me.”
  • 54. “I have no more flesh,” said the prince. “If you have not flesh, you have an Irish person,” said the serpent, “and don’t be telling your lies to me any longer. I knew from the beginning that you had an Irish person in the ship, and unless you throw her out to me, and quickly, I will eat yourself and your men.” Margaret came up, and no sooner did the serpent see her than she opened her mouth, and put on an appearance as if she were going to swallow the ship. “I will not be guilty of the death of you all,” said Margaret; “get me a boat, and if I go far safe it is better; and if I do not go, I had rather I perished than the whole of us.” “What shall we do to save you?” said Simon. “You can do nothing better than put me in the boat,” said she, “and lower me on the sea, and leave me to the will of God.” As soon as she got on the sea, no sooner did the serpent see her than she desired to swallow her, but before she reached as far as her, a billow of the sea rose between them, and left herself and the boat on dry land. She saw not a house in sight she could go to. “Now,” said she, “I am as unfortunate as ever I was. There is no place at all for me to get that I know of, and this is no place for me to be.” She arose and she began to walk, and after a long while she saw a house a good way from her. “I am not as unfortunate as I thought,” said she. “Perhaps I shall get lodging in that house to- night.” She went in, and there was no one in it but an old woman, who was getting her supper ready. “I am asking for lodging till morning.” “I will give you no lodging,” said the old woman. “Before I go farther, there is a boat there below, and it is better for you to take it into your hands.” “Come in,” said the old woman, “and I will give you lodging for the night.”
  • 55. The old woman was always praying by night and day. Margaret asked her, “Why are you always saying your prayers?” “I and my mother were living a long while ago in the place they call the White Doon, and a giant came and killed my mother, and I had to come away for fear he would kill myself; and I am praying every night and every day that some one may come and kill the giant.” The next morning there came a gentleman and a beautiful woman into the house, and he gave the old woman the full of a quart of money to say paters for them till morning. The old woman opened a chest and took out a handsome ring, and tried to place it on his finger, but it would not go on. “Perhaps it would fit you,” said she to the lady. But her finger was too big. When they went out Margaret asked the old woman who were the man and woman. “That is the son of a king of the Eastern World, and the name that is on him is Stephen, and he and the woman are going to the White Doon to fight the giant, and I am afraid they will never come back; for the ring did not fit either of them; and it was told to the people that no one would kill the giant but he whom the ring would fit.” The two of them remained during the night praying for him, for fear the giant should kill him; and early in the morning they went out to see what had happened to Stephen and the lady that was with him, and they found them dead near the White Doon. “I knew,” said the old woman, “this is what would happen to them. It is better for us to take them with us and bury them in the churchyard.” When they were buried, “Come home,” said the old woman, “and we’ll know who is the first person comes the same way again.” About a month after a man came into the house, and no sooner was he inside the door than Margaret recognised him. “How have you been ever since, Simon?”
  • 56. “I am very well,” said he; “it can’t be that you are Margaret?” “It is I,” said she. “I thought that billow that rose after you, when you got into the boat, drowned you.” “It only left me on dry land,” said Margaret. “I went to the Eastern World, and my father said to me that he sent my brother to go and fight with the giant, who was doing great damage to the people near the White Doon, and that my wife went to carry his sword.” “If that was your brother and your wife,” said Margaret, “the giant killed them.” “I will go on the spot and kill the giant, if I am able.” “Wait till I try the ring on your finger,” said the old woman. “It is too small to go on my finger,” said he. “It will go on mine,” said Margaret. “It will fit you,” said the old woman. Simon gave the full of a quart of money to the old woman, that she might pray for him till he came back. When he was about to go, Margaret said, “Will you let me go with you?” “I will not,” said Simon, “for I don’t know that the giant won’t kill myself, and I think it too much that one of us should be in this danger.” “I don’t care,” said Margaret. “In the place where you die, there am I content to die.” “Come with me,” said he. When they were on the way to the White Doon, a man came before them. “Do you see that house near the castle?” said the man.
  • 57. “I see,” said Simon. “You must go into it and keep a candle lighted till morning in it.” “Where is the giant?” said Simon. “He will come to fight you there,” said the man. They went in and kindled a light, and they were not long there when Margaret said to Simon,— “Come, and let us see the giants.” “I cannot,” said the king, “for the light will go out if I leave the house.” “It will not go out,” said Margaret; “I will keep it lighted till we come back.” And they went together and got into the castle, to the giant’s house, and they saw no one there but an old woman cooking; and it was not long till she opened an iron chest and took out the young giants and gave them boiled blood to eat. “Come,” said Margaret, “and let us go to the house we left.” They were not long in it when the king’s son was falling asleep. Margaret said to him, “If you fall asleep, it will not be long till the giants come and kill us.” “I cannot help it,” he said. “I am falling asleep in spite of me.” He fell asleep, and it was not long till Margaret heard a noise approaching, and the giant cried from outside to the king’s son to come out to him. “Fum, faw, faysogue! I feel the smell of a lying churl of an Irishman. You are too great for one bite and too little for two, and I don’t know whether it is better for me to send you into the Eastern World with a breath or put you under my feet in the puddle. Which would you rather have—striking with knives in your ribs or fighting on the grey stones?”
  • 58. “Great, dirty giant, not with right or rule did I come in, but by rule and by right to cut your head off in spite of you, when my fine, silken feet go up and your big, dirty feet go down.” They wrestled till they brought the wells of fresh water up through the grey stones with fighting and breaking of bones, till the night was all but gone. Margaret squeezed him, and the first squeeze she put him down to his knees, the second squeeze to his waist, and the third squeeze to his armpits. “You are the best woman I have ever met. I will give you my court and my sword of light and the half of my estate for my life, and spare to slay me.” “Where shall I try your sword of light?” “Try it on the ugliest block in the wood.” “I see no block at all that is uglier than your own great block.” She struck him at the joining of the head and the neck, and cut the head off him. In the morning when she wakened the king’s son, “Was not that a good proof I gave of myself last night?” said he to Margaret. “That is the head outside, and we shall try to bring it home.” He went out, and was not able to stir it from the ground. He went in and told Margaret he could not take it with him, that there was a pound’s weight in the head. She went out and took the head with her. “Come with me,” said he. “Where are you going?” “I will go to the Eastern World; and come with me till you see the place.” When they got home Simon took Margaret with him to his father the king.
  • 59. “What has happened to your brother and your wife?” said the king. “They have both been killed by the giants. And it is Margaret, this woman here, who has killed them.” The king gave Margaret a hundred thousand welcomes, and she and Simon were married,[11] and how they are since then I do not know. [11] Simon’s wife, mentioned at the beginning of the story, has apparently been forgotten.
  • 60. THE SON OF THE KING OF PRUSSIA. Narrator, P. M’Grale, Achill, co. Mayo. There were giants at that time, and every seven years three daughters of kings were left to them to be eaten, unless some one were found to fight them. In this year the kings came together, and they cast lots to see which of them should give his children to the giants to be eaten. And the lot fell on the High King of Erin to give his three daughters to the giants. Then came the son of the King of Prussia to ask the king’s daughter in marriage, and the king said he could not give her to him unless he would fight the giants, and he said he would fight if he got good feeding. And the king asked him, “What sort of food would you like best?” Said he, “Marrow of deer and sinews of beeves.” And the king said he would give him that. There were servants killing for him his sufficiency of food, and he rose out, the son of the King of Prussia, and he went among the work-people, and when he would strike one of them a blow of his fist and kill him the king would not say anything for fear of making him angry. Then, when he came within a month of the time, he went to the glen, and tools with him to make a hole in the glen, and he was at home every evening, and he dirty. When it came within a week of the time, the son of the King of Scotland spoke to his father. Said he, “A good neighbour to you was the King of Erin ever.” “Good he was, my son, and I to him likewise.” “And he never put war nor battle on you.” “Nor I on him, my son.”
  • 61. “I am making one request of you, father.” “Every request you make of me I will give you, except to go to fight in Erin.” “Won’t you give me that, father?” “I have fear of your getting married.” “My hand and my word to you, father, that that woman I will not wed till I come back to you.” “With that request, go, and I will give you my blessing.” He went with himself, then, and he arrayed himself in his clothes, and the stars of the son of a king by a queen were on the breast of his coat, and a poor man’s suit outside, till he came to the sea, and took a great ship, till he came to Erin, and drew up his ship on the land, and put on her fastening for a day and a year, though he might chance to be there but an hour. He went then to the house of the hen-wife, and asked for lodging; and he got lodging for the night; and the old woman asked him what was the news, and he said he had no news at all unless he would get it from her. “I’d say,” said she, “that it was under a docking you came out, when you’ve heard nothing of the great gathering that’s to be here to-morrow. There are three giants to come, on three days, one after the other, and they are to get the three daughters of the King of Erin, and the son of the King of Prussia, is to fight for them; and, if he kills the giants, the first person to-morrow that brings the news the giant’s head is cut off, will get a shovel of gold.” Then the poor man and the hen-wife spent the night pleasantly, and in the morning he got up and washed his hands and his face, and ate his breakfast, and went to the glen, and he sat down in a clump of ferns, brambles, and nettles, and there was he. Then the king and his people went drawing to the glen, and when they were near it the son of the King of Prussia told them to go
  • 62. home, for fear the giant might come and kill some of them before he could stop him. The king and his people went home and left the son of the King of Prussia and the young girl in the glen, and she sat down on a stone chair, and the son of the King of Prussia was coming about her, thinking to make free with her, till he ran to his hole and left her there. Then he saw the ship coming under sail, three lengths before she came near to land, and the giant cast anchor, and gave a step on the land, and he all but sank the ship after him; and the land, when he came on it, shook so greatly that the old castles fell, and the castles that were made last stooped; every (old) tree was broken, and the young tree was bent; and he left not foal with mare, nor calf with cow, nor lamb with sheep, nor hare in a bush, nor rabbit in hole, that didn’t go off in terror. And he came up to the girl and put the tip of his finger under the edge of her girdle, and threw her over the tip of his shoulder. “My mischief and misfortune! Hadn’t your father a man, cow-boy nor sheep-boy, to-day to fight me? Or where is the son of the King of Prussia, who has been feeding for a year to fight me? Don’t think it’s on feather beds I’ll put you, nor up the stairs, when I bring you home; but you are big for one bite and small for two, and if I had a grain of salt I would eat you at one bite; and small is the morsel you are between myself and my two brothers.” He went with her, drawing to the ship to get on board; and the son of the King of Scotland spoke to him, and said he should not get her like that without fighting. And the giant said that it wasn’t worth his while to let her out of his hands, but for him to come and prevent him taking her with him. But the other man said that was not right, that he should put the woman down on the land, and fight honourably. And then the giant asked him which he liked best, wrestling on the red flagstones, or green knives at the top of his ribs. He said that he liked best wrestling on the red flagstones, in the place where his noble white feet should be rising above the giant’s clumsy club feet. The two champions caught hold of each
  • 63. other in the grip of the close, keen wrestling. If you were to go seeking for sport from the west of the world to the world’s beginning, it is to that pair you would go. They made soft of the hard, and hard of the soft, till they drew the springs of fresh water under the red stones; till the son of the King of Scotland remembered that he came there without the King of Erin knowing, nor his daughters, that he was come; and also that his father was not pleased with his coming; and he gave the giant a squeeze, and put him down to his two knees in the ground, and the second squeeze to the waist of his trousers, and the third squeeze to the back of his neck. “A green sod over you, churl!” “Stay, stay! best of champions that ever I saw. I am but a third of the world, and my brother is the half of the world, and the other is as strong as the world; and if you spare me, I and my brothers will be your helpers, and we will conquer the world.” “That’s not what I will do,” said the son of the King of Scotland; “but I will cut the head off you.” And he caught hold of his sword and cut the head off the giant. And the young girl all the time was watching the young champion; and she ran to him and kissed him, and asked him if he would come home with her, and he said he would not come. She took a pair of scissors and cut away a piece of the champion’s suit that was on him. He went with himself then, and came to the hen-wife, and told her that the giant’s head was cut off; and she asked him if any one was before her to the king with the news. And she ran to the king and told him the giant’s head was cut off, and he gave her a shovel of gold as the reward of her trouble. When the son of the King of Scotland was gone, the son of the King of Prussia arose out of his hole, and he took with him a book and a knife, and he swore that unless she said it was he had done the action, he would cut the head off her father and every one of
  • 64. them. He took his sword and he cut a piece from the giant’s head, and took it home in proof that he killed the giant. The king came and his hosts before him, and they raised him on their shoulders and carried him home. And there was great joy on the king and his people that the giant was killed; and the two other sisters were cheerful; but there was dissatisfaction and sorrow and trouble on the third sister, and she spoke not a word to them except to say, “You will have it yet.” The king spent the night cheerfully, till the whiteness of the day came upon the morrow. The next day the second sister went out, and the son of the King of Scotland fought for her, and when he would not go home with her, she cut off a lock of his hair; but the son of the King of Prussia said it was he killed the giant. And the next day the third sister went out, and the son of the King of Scotland killed the third giant. The girl asked him would he go home with her, and he said he would not, and she took with her one of his shoes. And when the son of the King of Prussia went home, and the third giant killed by the son of the King of Scotland, proclamation was made of the marriage of the son of the King of Prussia, and the daughter of the King of Erin. And when they ate their supper, word was sent to the priest of the pattens and the clerk of the table, (to come) to marry them. And the hen-wife came and the champion to the wedding; and they arose that the pair might be married. The priest asked the girl if she would marry that man, and she said she would not. And he struck her a box with his fist, and said, “How do you know that you are my choice? Haven’t I my choice of the family to get?” And the king said he had. Then came the second daughter, and the priest asked her, would she marry him? and she said she would not. And he struck her a blow of his fist, and he said, “How do you know that you are my choice? Haven’t I my choice of you to get?” And the king said he had.
  • 65. Then came the third girl, and the priest asked her, would she marry him? and she said she would not. And the son of the King of Prussia gave her a blow of his fist, and he said, “How do you know that you are my choice? Haven’t I my choice of you to get?” And the king said he had. Then the Scotchman got up and he gave the son of the King of Prussia a blow with the tip of his boot and knocked him down. And the king offered a reward of five pounds to whoever would tell who struck the champion. And, as there were bad people present, he was told it was the old man down there who had struck him. He was caught, and he was bound, and when the daughters saw him they knew him, and they threw themselves on their knees before their father and begged he would grant them one request; and he said he would, but that one of them must marry the man. “It is not for that man we are asking, but for this one, who saved us.” He put the three daughters in three rooms, and he called the eldest, and she came to him and told him that he was the man who saved her. She put her hand in her pocket and she took out the piece she cut from his champion’s suit, and it answered to the coat. Then the king called the second daughter, and she said likewise, and showed the lock of hair, and her father was satisfied. He called the third daughter, and she showed the shoe, and she said she had no fear of him, that he it was who saved her. The Scotchman got up standing, and he bound the son of the King of Prussia, and they were going to put him to death. Then the daughters asked the son of the King of Scotland if he would marry any of them, and he said that to one of them he was bound; but that when he knew what the son of the King of Prussia was going to do he came without[12] his father’s leave to Erin to save them, “and I cannot marry a woman till I go to my father and then I will come back to you.”
  • 66. And the daughter said, “Marry one of us and then go to your father, and then you can come back.” He said he could not do that, that he would go to his father first. Said she,— “If you do not marry one of us, I will put you for a year under disesteem and bad esteem; every one will be spitting on you and cursing you; whoever is meanest you shall be under his curses; and till you marry one of us, or get cause for laughter, your mouth to be at the back of your head.” And when he saw that, “If I were going this hour to marry you, I would not marry you now.” The disfigurement came on him. He turned to the door and opened his hand, and all that were between him and the door he killed. He went on from place to place in hopes of getting a cure for himself, and he left not a doctor in the place that he was not getting the water of healing and every sort of drugs from them. He was going till a man met him who was giving food and work to every one, and he went to him and asked him for work. The man said he would give it if the workmen would take him. He had eighteen men, six of them each in different places he had, and he went up to one set of six and said to them, “Here is a helper I am bringing you; I don’t think he’ll increase our work, and I myself will give him enough to eat.” They spat upon him and said they would not have him. Then they came to another six, and they would not take him; and they came to another, and they took him. And when the master went away, Crooked-mouth said he was sleepy, and asked for leave to sleep that day. And they gave him leave; and in the night he told them not to go out to work in the morning until he came in to his breakfast, and when he came in to his breakfast the work of a week was done. And those six were walking about and not doing a turn.
  • 67. At that time a gentleman sent an invitation to dinner to the man (who had the workmen) and for his men to come with him. And they went drawing that way, and a robber met them on the road and bound every one of them and took his money from the master. And he told his men to bind Crooked-mouth, and Crooked-mouth said that not one should bind him but the robber himself. “Come up to me and I’ll bind you. You won’t be having your stories to make of me.” When he went to bind him, Crooked-mouth laid hold of him, and turned him round, and threw him on the ground, and told him to hand out his master’s money quickly, or he would kill him. So he gave him the money back and loosed the men. “Master,” said he, “here are twelve others for him, and I will do their work.” “Oh!” said the master, “I will not ask one turn of you, except one meal and one drink for ever.” So he gave over to the robber the twelve other men, who had refused to let him work with them. And before he parted with the robber he put him under obligations. “I will not kill you,” said he, “this is O’Daly, and I am Gerald O’Daly, and anything at all that’s ever asked of you by the honour of O’Daly, do that.” Then they went on with themselves to the house, and there was a feast ready for them; and they took their meal, and while they were eating, the twelve others he gave over to the robber came. One of them asked the robber to let them go their way by the honour of O’Daly, and he told them to go and a hundred welcomes, and if it were a greater thing (he would grant it). When Crooked-mouth ate his supper, he stretched himself under the table, and when the others ate their supper, (the gentleman) put them out to sleep in the barn, and when he came in he heard snoring, and he gave the man a kick, and asked him why he wasn’t
  • 68. with the others, and he said he would not leave the house that night; and the man of the house said that he must leave; that no one slept in the house for a year, and that he should not sleep in it that night. But the other said he would sleep in it, and find out about everything in the house. He took the man of the house and put him in a basket, and put him in the chimney to smother him; and he asked him, “Let me down, and I will tell you.” He let him down, but he would not tell him; and he put him back three times one after another, and the third time he came down he told him. “I was one day standing at the gable of my house, and I saw a ship coming under full sail into the harbour, and a man and a woman jumped out (on the shore) and ran; and I saw a great monster in the sea coming the same way, and the monster ran after them; and the man put his hand in his pocket, and pulled out something, and flung it at the monster; and the monster sent out such a spout of blood that the two were drowned in it. I took them with me and washed them, and I put herbs of the hill on them, and I have had them for two years, and there is not a night since that I don’t burn a penny candle looking at their beauty.” He opened a room and showed them to Crooked-mouth, and he took the water of healing and sprinkled some of it on them, and they arose alive again. And his mouth came as it was at first, and the disfigurement went from him, and he asked his brother what it was took him that way. And his brother said,— “When you were gone a day and a year I went to the sea, hoping to see a ship or boat that would give me tidings of you, or to see if I would see a board that I would recognise; and one day I met a pretty bird-serpent, and a stone with him, and it was written on the stone that that was the stone that would kill the bird; and I took the stone and the bird home with me, and I put the bird into a cage, and kept it there for a week, and it became so big I had to put it into the stable; and it went on growing bigger and bigger till I had to make a place for it in the wood, and to tie the brambles round it, and I had four men killing beef and giving it food. And one day I was
  • 69. walking round near it, and it made a lunge at me to eat me, and I said it would do that at last. I went and took a ship, and went to sea, and I was sailing three days when my sister rose up to me, and I did not know she was on board the ship. We were sailing till we came to the harbour, and the serpent was following us, and I went up on the land, and the serpent followed; and, as God was helping me, I had my waistcoat on that day, and the stone was in the pocket, and I flung the stone at her, and she spouted so much blood that I and my sister were drowned. I don’t know what happened to us since then.” “I took you with me, and cleansed you, and put herbs of the hill round about you, and there is not a night for two years I don’t burn a penny candle looking on you, and I believe that it is I should get her in marriage.” The four spent the night pleasantly, telling one another everything; and in the morning when they arose, and the people who were at supper the night before were gathered together, the master did not recognise that Crooked-mouth was with him. But when Crooked-mouth told him that it was he was there, O’Daly bade him come with him, but he would not. He went with his brother and his sister and the other man to Scotland. And when they came to his father’s court, his father was banished by Faugauns and Blue-men; and he and the other people who were taking possession of his father’s court began; and he and they spent three nights and three days killing one another, and on the third day he had killed and banished them all. But when he and the cat met, the cat killed him and he killed the cat; and his brother was going everywhere that he killed, and at last he found him and the cat dead. And he searched his pocket and found in it the bottle of healing-water, and as he was drawing the cork from the bottle, some of the water fell on the dead man, and he arose alive again. He went then with his sister and the other man who was in the place of husband to his sister; and they cleansed the king’s castle, and he brought his father and mother and their people home to the
  • 70. castle, and they were well from that out. Then he gave his sister in marriage to the man, who found himself and her on the day when the serpent drowned them. There came the priest of the pattens and the clerk of the table, and the pair were wedded. He himself then went back to Erin, and married the daughter of the King of Erin, who was to be eaten by the giants, and the son of the King of Prussia was to save her. [12] This contradicts what is stated on page 140.
  • 71. BEAUTY OF THE WORLD. Narrator, P. Minahan, Malinmore, Glencolumkille, co. Donegal. There was a king then, and he had but one son. He was out hunting. He was going past the churchyard. There were four men in the churchyard and a corpse. There was debt on the corpse. The king’s son went in. He asked what was the matter. Said one of the men: “The dead man is in our debt. I am not willing to bury the body, till the two sons who are here, promise to pay the debts.” “We are not able to pay,” said one of them. “I have five pounds,” said the king’s son; “I will give them to you to bury the body.” He gave the five pounds. The body was buried. The king’s son went hunting. He went home in the evening. In the morning of the morrow there was snow. He went out hunting in the snow. He killed a black raven. He stood over it and looked at it. He said in his own mind he would never marry a woman whose head was not as black as the bird’s wing, and her skin as white as the snow, and her cheeks as red as the blood on the snow. He went home. On the morning of the morrow, when he rose, he washed himself, and he went away to find the woman. When he was going for a time, he met with a red-haired young man. The young man saluted him. He asked him where he was going. The king’s son told him he was going to get one sight of that woman. “It is better for you to hire me,” said the young man. “What wages do you be asking?” “Half of all we gain, to the end of a year and a day.”
  • 72. The two went on with themselves till the evening came. Said the red man: “There is a man related to me living in this wood below. Do you wait here till I go down to him.” The red man went down to the house of the giant. The giant was sitting on a chair by the fire. “Uncle, dear,” said the red man, “is it like this you are?” “Yes, kinsman mine: what is coming to me?” Said the red man: “The King of the prodigious Eastern World is coming up to kill you. Get out of the way as quick as you can.” “I have an iron house outside there. Lock me into it.” He locked the man in. He went to his master. He took his master up to the house of the giant. He got ready their supper. They went to rest. This was the giant’s cry in the morning. “Let them open.” The red man went to him. He asked him what was the matter. “I am ready to perish with hunger. Let me out of this quickly.” “I will not let you out,” said the red man, “till you tell me where the dark cloak is.” “That is what I will never tell any one.” “Well, if you like better not to tell, you will be there till you die.” “Sooner than be here any longer, it is hanging in such a room.” “I know where it is,” said the red man. “Be here as long as you like.” When the giant heard that he would not get out, he took a jump out between two bars of the iron house. Two halves were made of him. Half fell outside and half inside. The red man went to the giant’s house. He got ready the breakfast. He and his master breakfasted. He took with them plenty of gold and silver, two horses and two saddles. They went till evening was there, and they went into another wood.
  • 73. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebooknice.com