M1 Ktunotes - in
M1 Ktunotes - in
Web basics
• Fundamentals of web-based interactions between a client web browser and a web
server.
• In its simplest form, a web page is nothing more than an HTML (HyperText Markup
Language) document (with the extension .html or .htm) that describes to a web browser
the document’s content and structure
Hyperlinks
• HTML documents normally contain hyperlinks, which, when clicked, load a
specified web document. Both images and text may be hyperlinked.
• When the mouse pointer hovers over a hyperlink, the default arrow pointer changes
into a hand with the index finger pointing upward. Often hyperlinked text appears
Downloaded from Ktunotes.in
underlined and in a different color from regular text in a web page.
• Hyperlinks are widely used to reference sources, or sites that have more information
on a particular topic. The paths created by hyperlinking create the effect of the
“web.”
• When the user clicks a hyperlink, a web server locates the requested web page and
sends it to the user’s web browser.
• Similarly, the user can type the address of a web page into the browser’s address
field and press Enter to view the specified page.
• Hyperlinks can reference other web pages, e-mail addresses, files and more. If a
hyperlink’s URL is in the form mailto:emailAddress, clicking the link loads your
default e-mail program and opens a message window addressed to the specified e-
mail address. If a hyperlink references a file that the browser is incapable of
displaying, the browser prepares to download the file, and generally prompts the
user for information about how the file should be stored. When a file is downloaded,
it’s copied onto the user’s computer. Programs, documents, images, sound and
video files are all examples of downloadable files.
Introduction to HTML5
• Unlike programming languages, such as C, C++, C#, Java and Visual Basic, HTML5
is a markup language that specifies the structure and content of documents that are
displayed in web browsers.
Editing HTML5:
➢ We’ll create HTML5 documents by typing HTML5 markup text in a text editor (such
as Notepad, TextEdit, vi, emacs) and saving it with the .html or .htm filename
extension.
Downloaded from Ktunotes.in
➢ Computers called web servers store HTML5 documents. Clients (such as web
browsers running on your local computer or smartphone) request specific resources
such as HTML5 documents from web servers.
Example HTML5:
➢ This first example displays the message Welcome to HTML5! in the browser.
➢ Blank Lines
We include blank lines (lines 2 and 10) to make our documents easier to read—the browser
ignores them.
Lines 3–4 are HTML5 comments. We’ll insert comments in your HTML5 markup to improve
readability and describe the content of a document. The browser ignores comments when your
document is rendered. HTML5 comments start with <!-- and end with -->. We include in our
examples comments that specify the figure number and file name and state the example’s
purpose. We’ll often include additional comments, especially to explain new features.
HTML5 markup contains text (and images, graphics, animations, audios and videos) that
represents the content of a document and elements that specify a document’s structure and
meaning. Some important elements are:
- the html element (which starts in line 5 and ends in line 14)
The html element encloses the head section (represented by the head element) and the body
section (represented by the body element). The head section contains information about the
HTML5 document, such as the character set (UTF-8, the most popular character-encoding
scheme for the web) that the page uses (line 7)—which helps the browser determine how to
render the content—and the title (line 8). The head section also can contain special document-
formatting instructions called CSS3 style sheets and client-side programs called scripts for
creating dynamic web pages..
HEADINGS
• Some text in an HTML5 document may be more important than other text.
• HTML5 provides six heading elements (h1 through h6) for specifying the relative
importance of information (shown in figure)
• Heading element h1 is considered the most significant one and is typically rendered in
a larger font than the other five. Each successive heading element (h2, h3, etc.) is
typically rendered in a progressively smaller font.
• The text size used to display each heading element can vary between browsers.
• Placing a heading at the top of each page helps viewers understand the purpose of the
page. Headers also help create an outline for a document and are indexed by search
engines.
LINKING
• One of the most important HTML5 features is the hyperlink, which references (or
links to) other resources, such as HTML5 documents and images.
• When a user clicks a hyperlink, the browser tries to execute an action associated with
it (for example, navigate to a URL or open an e-mail client). Any displayed element
can act as a hyperlink.
• Web browsers typically underline text hyperlinks and color their text blue by default
so that users can distinguish hyperlinks from plain text. In Figure created text
hyperlinks to four websites.
• Line 13 introduces the strong element, which indicates that its content has high
importance. Browsers typically render such text in a bold font.
• Links are created using the a (anchor) element. Line 16 defines a hyperlink to the URL
assigned to attribute href (hypertext reference), which specifies a resource’s location,
such as
➢ a web page or location within a web page
➢ a file
➢ an e-mail address
• The anchor element in line 16 links the text Facebook to a web page located at
http://www.facebook.com.
• The browser changes the color of any text link once you’ve clicked the link (in this
case, the links are purple rather than blue).
• When a URL does not indicate a specific document on the website, the web server
returns a default web page. This page is often called index.html, but most web servers
can be configured to use any file as the default web page for the site. If the web server
cannot locate a requested document, it returns an error indication to the web browser
(known as a 404 error), and the browser displays a web page containing an error
message.
IMAGES
The most popular image formats used by web developers today are PNG (Portable Network
Graphics) and JPEG (Joint Photographic Experts Group).
Users can create images using specialized software, such as Adobe Photoshop Express
(www.photoshop.com), G.I.M.P. (www.gimp.org), Inkscape (www.inkscape.org) and many
more. Figure below demonstrates how to include images in web pages.
- alt Attribute
• A browser may not be able to render an image for several reasons. It may not support
images—as is the case with text-only browsers—or the client may have disabled image
viewing to reduce download time. Every img element in an HTML5 document must
have an alt attribute. If a browser cannot render an image, the browser displays the alt
attribute’s value.
• The alt attribute is also important for accessibility—speech synthesizer software can
speak the alt attribute’s value so that a visually impaired user can understand what the
browser is displaying. For this reason, the alt attribute should describe the image’s
contents.
-void Elements
• Some HTML5 elements (called void elements) contain only attributes and do not mark
up text (i.e., text is not placed between a start and an end tag). Although this is not
required in HTML5, we can terminate void elements (such as the img element) by using
the forward slash character (/) inside the closing right angle bracket (>) of the start tag.
<img src = "jhtp.png" width = "92" height = "120" alt
= "Java How to Program book cover" />
results in a syntax error because it uses the less-than character (<), which is reserved
for start tags and end tags such as <p> and </p>.
• HTML5 provides character entity references (in the form &code;) for representing
which uses the character entity reference < for the less-than symbol (<). [Note:
Before HTML5, the character entity reference & was required to display an & in
a web page. This is no longer the case.]
LISTS
• Figure above displays text in an unordered list (i.e., a simple bullet-style list that does
not order its items by letter or number). The unordered-list element ul (lines 16–22)
creates a list in which each item begins with a bullet symbol (typically a disc). Each
entry in an unordered list is an li (list item) element (lines 18–21). Most web browsers
Nested List
• Lists may be nested to represent hierarchical relationships, as in a multilevel outline.
Figure below demonstrates nested lists and ordered lists. The ordered-list element ol
creates a list in which each item begins with a number.
• In many browsers, the items in the outermost unordered list (lines 15–55) are preceded
by discs. List items nested inside the unordered list of line 15 are preceded in many
browsers by hollow circular bullets.
• A web browser indents each nested list to indicate a hierarchical relationship. The
first ordered list (lines 29–33) includes two items. Items in an ordered list are
enumerated 1., 2., 3. and so on.
• Nested ordered lists are enumerated in the same manner. Although not
demonstrated in this example, subsequent nested unordered list items are often
preceded by square bullets. The bullet styles used may vary by browser.
Figure below is a simple form that sends data to the web server for processing.
• The web server typically returns a web page back to the web browser—this page often
indicates whether or not the form’s data was processed correctly
The form is defined in lines 20–43 by a form element. Attribute method (line 20) specifies
how the form’s data is sent to the web server. Using method = "post" appends form data to the
browser request, which contains the protocol (HTTP) and the requested resource’s URL. This
method of passing data to the server is transparent—the user doesn’t see the data after the form
is submitted. The other possible value, method = "get", appends the form data directly to the
end of the URL of the script, where it’s visible in the browser’s Address field.
l <!DOCTYPE html>
2
3 <!-- Fig. 2.1 :=arm.html-->
4 <!-- Form w:.th a text field and h:.dcten f:.elds.-->
s <html>
6 <head>
7 <meta charset = "utf-8">
8 <tide>Forms<ftitle>
9 <!head>
10
11 <body>
12 <hl>Feedback Form<Jhl>
13
14 <p>Please fill out this form to help
15 us improve our site.<lp>
16
17 <!-- this tag starts the the form, gives the-->
18 <!-- method of sending in=ormat:.on and the-->
19 <!-- location of the form-process:.ng scr:.pt -->
20 <form method = "post" action = "http://www.deitel.c.om">
21 <!-- h:.dden inputs contain non-visual-->
22 <!-- information that will a:so be submitted-->
23 <input t)-pe = "hidden" name = "recipient"
24 ,·alue = ''deitel@deitel.com''>
25 <input -pe = "hidden" name = "subject"
26 ,·alue = "Feedback Form">
• Forms can contain visual and nonvisual components. Visual components include
clickable buttons and other graphical user interface components with which users
interact. Nonvisual components, called hidden inputs (lines 23–28), store any data that
we specify, such as e-mail addresses and HTML5 document file names that act as links.
• The three hidden input elements in lines 23–28 have the type attribute hidden, which
allows you to send form data that’s not given by a user. The hidden inputs are an e-mail
address to which the data will be sent, the e-mail’s subject line and a URL for the browser
to open after submission of the form. Two other input attributes are name, which
identifies the input element, and value, which provides the value that will be sent (or
posted) to the web server. The server uses the name attribute to get the corresponding
value from the form.
The text input in lines 32–33 inserts a text field in the form. Users can type data in text
fields. The label element (lines 31–34) provides users with information about the input
element’s purpose. The input element’s size attribute specifies the number of characters
visible in the text field. Optional attribute maxlength limits the number of characters input
into the text field—in this case, the user is not permitted to type more than 30 characters.
Two input elements in lines 40–41 create two buttons. The submit input element is a button.
When the submit button is pressed, the form’s data is sent to the location specified in the
form’s action attribute. The value attribute sets the text displayed on the button. The reset
input element allows a user to reset all form elements to their default values. The value
attribute of the reset input element sets the text displayed on the button (the default value is
Reset if you omit the value attribute).
META ELEMENTS
• Search engines catalog sites by following links from page to page (often known as spidering
or crawling the site) and saving identification and classification information for each page.
• One way that search engines catalog pages is by reading the content in each page’s meta
elements, which specify information about a document. Using the meta element is one of
many methods of search engine optimization (SEO)—the process of designing and tuning
your website to maximize your findability and improve your rankings in organic (non-paid)
search engine results.
• Two important attributes of the meta element are:
->name-which identifies the type of meta element
1. <input type="text">:
<input> element of type "text" are used to define a single-line input text field.
E.g;
<form>
<label>Enter first name</label><br>
<input type="text" name="firstname"><br>
<label>Enter last name</label><br>
<input type="text" name="lastname"><br>
<p><strong>Note:</strong>The default maximum cahracter lenght
is 20.</p>
</form>
2. <input type="password">:
The <input> element of type "password" allow a user to enter the password securely in a
webpage. The entered text in password filed converted into "*" or ".", so that it cannot be read
by another user.E.g;
<form>
<label>Enter User name</label><br>
<input type="text" name="firstname"><br>
<label>Enter Password</label><br>
<input type="Password" name="password"><br>
<br><input type="submit" value="submit">
</form>
Output
<form action="https://www.javatpoint.com/html-tutorial">
<label>Enter User name</label><br>
<input type="text" name="firstname"><br>
<label>Enter Password</label><br>
<input type="Password" name="password"><br>
<br><input type="submit" value="submit">
</form>
Output
4. <input type="reset">:
The <input> type "reset" is also defined as a button but when the user performs a click event,
it by default reset the all inputted values.E.g;
<form>
<label>User id: </label>
<input type="text" name="user-id" value="user">
<label>Password: </label>
<input type="password" name="pass" value="pass"><br><br>
<input type="submit" value="login">
<input type="reset" value="Reset">
</form>
https://www.javatpoint.com/html-form-input-types
Example
<!DOCTYPE html>
<html>
<body>
<form action="#">
Birthday (date and time): <input type="datetime-local" name="bdayt me">
<input type="submit">
</form>
</body>
</html>
Define a field for an e-mail addres (will be automatically · alidated when submitted):
</badly>
fa a cript:
Define a field for entering a number (You can also set restrictions on what m:unbers are
accepted}:
1na ="5">
<!DOCTYPE
<1body>
Tip: U ,e the reset butron ,carefuHyTIt ,can b annoying for u ers who
:aeciden1tally act vate the reset butron.
<1body>
<Jbody>
<1body>
<fonn actioo="#'1>
<fhitml>
<1body>
action="#'1,.
<1body>
<form action"""d mo_form.asp'1>
• The autocomplete attribute(line 18) can be used on input types to automatically fill in
the user’s information based on previous input. Such as name, address ,or email.
• We can enable autocomplete for an entire form or just for specific elements.
• E.g;An online order form might set autocomplete=”on” for the name and address
inputs and set autocomplete=”off” for the credit card and password inputs for security
purposes.
Datalist Element
• The datalist element (lines 32-47) provides input options for a text input element. At
the time of this writing,datalist support varies by browser.
• In the below example we use a datalist element to obtain the user’s birth month.
• The <datalist> tag is used to provide an "autocomplete" feature on <input> elements.
• Users will see a drop-down list of pre-defined options as they input data.
• Use the <input> element's list attribute to bind it together with a <datalist> element
• HTML5 introduces several page structure elements that meaningfully identify areas of
the page as headers,footers,navigation areas,asides,figures and more.
1. Header Element
Creates a header for this page that contains both text and graphics.The header
element can be used multiple times on a page and can include HTML
headings(<h1 through h6>),navigation,images and logos and more.
E.g;Top of front side of newspaper.
Title element
It does not need to be enclosed in a header,enables us to identify a date ,a time
or both.
2. Nav Element
This element groups navigation links.
Given example used the heading “Recent Publications” and created a ‘ul’ element
with seven ‘li’ elements that link to the corresponding web pages for each book.
4. Article element
Describes standalone content that could be potentially be used or
distributed.E.g;news article,blog entry.
8. Meter element
Renders a visual representation of a measure within a range.
E.g the total responses in the survey.min attribute is “0” and max attribute is “54”.
The value attribute is “14” representing the total number of people who responded
“yes” to the survey question.
9. Footer element
Describes a footer content that usually appears at the bottom of the content or
section document.
10. Text-Level Semantics:mark Element and wbr element Mark :element
highlights the text that is enclosed in the element.
Wbr:element indicates the appropriate place to break a word when the text wraps to
multiple lines.We use wbr to prevent a word from breaking in an awkward place.