Unit-2 Material
Unit-2 Material
Web developers use different programming languages depending on what they’re building:
Some programming languages apply to the front end, or client side. Front-end web development
codes all the interfaces and visuals a user sees—from buttons to graphics, Languages like HTML
Other programming languages, like Python and Java, are primarily for backend web development.
These so-called “server-side languages” handle communication between the front-end interface
A full-stack developer can code on both the front and back end, a skillset that requires broader language
1. JavaScript
In 2020, for the eighth year running, JavaScript topped the list of most popular programming languages in
StackOverflow’s Developer Survey. Along with CSS and HTML, JavaScript is one of the three core web
programming languages.
JavaScript is a scripting language. It runs directly from its source code; it doesn’t need to be translated into
JavaScript is also a full-stack language—though it’s most commonly used on the front end. JavaScript
Clickable buttons
and more.
Programmers also use JavaScript to create server-side applications using the runtime
environment Node.js. Node.js lets developers write JavaScript programs for operating systems like Linux,
JavaScript is satisfying to use and relatively quick to learn, thanks to a massive user community and plenty
of documentation. Once you’re familiar with the basics of JavaScript, you can start using libraries and
React.js and React Native are open-sourced resources for front-end development.
With React.js, you build, arrange, and render reusable components. This makes app development simpler
and more maintainable. React.js also uses a virtual document object model (DOM), which means you can
React Native is a larger framework for developing native mobile applications, though some developers
have used it to build desktop apps. It uses React.js as its main library but adds much more functionality,
React is one of the most popular frameworks for modern web development.
AngularJS
AngularJS is an open-source structural framework for dynamic app construction. It uses HTML as its
template language but extends the available syntax so you can build and scale Rich Internet
Applications (RIAs). An RIA gives web apps more interactivity and visual appeal by integrating elements of
AngularJS creates single-page applications (SPAs). A SPA loads a single document and updates the
content of that document using JavaScript. This fast-tracks the loading process and improves app
performance.
AngularJS improves the SPA build process by providing:
Unit testability
As a cross-platform framework, AngularJS works on all major web browsers and can create mobile apps
2. Python
Python is a general-purpose language that’s intuitive to learn and capable of creating highly advanced
programs. In 2021, Python topped the list of most popular programming languages for the first time.
Most famous as the go-to programming language for machine learning, artificial intelligence, and data
science, Python is also one of the best languages for web development. Primarily used on the back end,
Python is an excellent language for beginners. Its syntax is simple and highly readable, even if it’s your first
coding language.
Python is also an object-oriented programming language; it divides your code into self-contained units that
Most importantly, Python boasts an extensive and growing collection of modules, libraries, and
frameworks—collections of pre-written code that let you scale app and software development quickly.
Django
Django was developed to meet the fast-paced needs of a newsroom, and it shows. This open-source
framework speeds the creation of functioning, scalable web applications, so you can build a functioning app
in a matter of hours.
With Django, you get almost every structural component you might need “out of the box,” letting you build
out the details of your app without wasting time on parts that have already been built. You also get pre-
packaged solutions for common web development tasks, including user authentication and site mapping.
Flask
Like Django, Flask is a Python framework designed to make web application programming easier. It’s a
microframework, so the focus is on simplicity. It’s easier to learn and launch than Django, but you can still
3. Ruby
Like Python, Ruby is an object-oriented programming language designed for usability. It’s popular among
Ruby is the basis for the popular Ruby on Rails framework for web applications. Like Ruby itself, Ruby on
Rails is intuitive for non-programmers to learn. It has a massive user community and plenty of tutorials, plus
Because RoR is so quick to learn, it lets developers build and launch minimum viable products (MVPs)
quickly. This makes it a popular framework for e-commerce brands like Shopify and Spree.
Jekyll
Jekyll is a simple static website generator that is based on Ruby. If you are interested in hosting static web
pages for simple content, such as a blog, Jekyll provides an easy way to combine Markdown, Liquid,
4. Swift
Swift is an open-source language for application development on Apple platforms. Built for modern app
developers, it’s designed for power and speed as well as safety. It features:
Interactive debugging .
Swift is a full-stack language that’s taking over from Apple’s older Objective-C code, but it’s compatible
enough that Objective-C developers can still use it. It’s also a great language for brand-new coders, thanks
5. HTML
HyperText Markup Language (HTML) is the most popular markup language in the world, and it is a must-
learn for front-end web developers. Compared to languages like JavaScript and Python, HTML is relatively
simple.
HTML is a declarative markup language. It defines the elements of a web page through labeling—it does
not process logic, manipulate data, or take inputs and produce outputs like a scripting language would. It is
strictly used for page structuring and templating. Most beginning front-end developers start by learning
HTML, and the format that web pages take when stored on servers.
HTML uses sections called “element blocks” to indicate parts of a website. Within those blocks, HTML adds
It’s impossible to code a functioning website without HTML. In fact, if you right-click on any web page (not
on a link) and select View Page Source, you can see the HTML for that site.
6. CSS
Cascading Style Sheets (CSS) works hand-in-hand with HTML. CSS is a styling language—a special kind
of declarative language that describes what HTML code should look like on-screen.
CSS can:
CSS is slightly more complex than HTML, but it’s still accessible to beginners and especially important
for web design. Once you learn the basics, you can expand your knowledge with extension languages like
7. PHP
PHP, short for Hypertext Preprocessor, is a server scripting language. This language creates scripts on
web servers that create customized responses for each user’s request—unlike what you’d get with a
Learning PHP lets you create web pages that have customized user interfaces. One well-known example
is WordPress, which uses PHP to structure and display thousands of different websites to visitors.
HTML-5
The major points of HTML are given below:
HTML is an acronym which stands for Hyper Text Markup Language which is used for creating web
pages and web applications. Let's see what is meant by Hypertext Markup Language, and Web page.
Hyper Text: HyperText simply means "Text within Text." A text has a link within it, is a hypertext.
Whenever you click on a link which brings you to a new webpage, you have clicked on a hypertext.
HyperText is a way to link two or more web pages (HTML documents) with each other.
Markup language: A markup language is a computer language that is used to apply layout and
formatting conventions to a text document. Markup language makes text more interactive and dynamic.
It can turn text into images, tables, links, etc.
Web Page: A web page is a document which is commonly written in HTML and translated by a web
browser. A web page can be identified by entering an URL. A Web page can be of the static or
dynamic type. With the help of HTML only, we can create static web pages.
Hence, HTML is a markup language which is used for creating attractive web pages with the help of
styling, and which looks in a nice format on a web browser. An HTML document is made of many
HTML tags and each HTML tag contains different content.
Basic Tags
HTML tags are like keywords which defines that how web browser will format and display the
content. With the help of tags, a web browser can distinguish between an HTML content and a simple
content. HTML tags contain three main parts: opening tag, content and closing tag. But some HTML tags
are unclosed tags.
<!DOCTYPE>
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
HTML Headings
<h1> defines the most important heading. <h6> defines the least important
heading.
Example :
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Search engines use the headings to index the structure and content of your web
pages.
Users often skim a page by its headings. It is important to use headings to show
the document structure.
<h1> headings should be used for main headings, followed by <h2> headings,
then the less important <h3>, and so on.
Note: Use HTML headings for headings only. Don't use headings to make
text BIG or bold.
HTML Paragraphs
A paragraph always starts on a new line, and browsers automatically add some
white space (a margin) before and after a paragraph.
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
The <hr> tag defines a thematic break in an HTML page, and is most often
displayed as a horizontal rule.
The <hr> element is used to separate content (or define a change) in an HTML
page:
Example
The <hr> tag is an empty tag, which means that it has no end tag.
Use <br> if you want a line break (a new line) without starting a new paragraph:
Example
The <br> tag is an empty tag, which means that it has no end tag.
Formatting Tags
HTML Formatting Elements
The HTML <b> element defines bold text, without any extra importance.
Example
<b>This text is bold</b>
The HTML <strong> element defines text with strong importance. The content inside is typically
displayed in bold.
Example
<strong>This text is important!</strong>
HTML <i> and <em> Elements
The HTML <i> element defines a part of text in an alternate voice or mood. The content inside is
typically displayed in italic.
Tip: The <i> tag is often used to indicate a technical term, a phrase from another language, a
thought, a ship name, etc.
Example
<i>This text is italic</i>
The HTML <em> element defines emphasized text. The content inside is typically displayed in
italic.
Tip: A screen reader will pronounce the words in <em> with an emphasis, using verbal stress.
Example
<em>This text is emphasized</em>
Example
<small>This is some smaller text.</small>
The HTML <mark> element defines text that should be marked or highlighted:
Example
<p>Do not forget to buy <mark>milk</mark> today.</p>
The HTML <del> element defines text that has been deleted from a document. Browsers will
usually strike a line through deleted text:
Example
<p>My favorite color is <del>blue</del> red.</p>
The HTML <ins> element defines a text that has been inserted into a document. Browsers will
usually underline inserted text:
Example
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>
HTML <sub> Element
The HTML <sub> element defines subscript text. Subscript text appears half a character below the
normal line, and is sometimes rendered in a smaller font. Subscript text can be used for chemical
formulas, like H2O:
Example
<p>This is <sub>subscripted</sub> text.</p>
The HTML <sup> element defines superscript text. Superscript text appears half a character
above the normal line, and is sometimes rendered in a smaller font. Superscript text can be used
for footnotes, like WWW [1]:
Example
<p>This is <sup>superscripted</sup> text.</p>
Adding Images
HTML Images Syntax
The HTML <img> tag is used to embed an image in a web page.
Images are not technically inserted into a web page; images are linked to web pages. The <img> tag
creates a holding space for the referenced image.
The <img> tag is empty, it contains attributes only, and does not have a closing tag.
Syntax
<img src="url" alt="alternatetext">
Note: When a web page loads, it is the browser, at that moment, that gets the image from a web
server and inserts it into the page. Therefore, make sure that the image actually stays in the same spot
in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon and
the alt text are shown if the browser cannot find the image.
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
The alt Attribute
The required alt attribute provides an alternate text for an image, if the user for some reason cannot
view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
If a browser cannot find an image, it will display the value of the alt attribute:
Example
<img src="wrongname.gif" alt="Flowers in Chania">
Tip: A screen reader is a software program that reads the HTML code, and allows the user to "listen"
to the content. Screen readers are useful for people who are visually impaired or learning disabled.
Example
<img src="img_girl.jpg" alt="Girl in a jacket" style="width:500px;height:600px;">
Example
<img src="img_girl.jpg" alt="Girl in a jacket" width="500" height="600">
The width and height attributes always define the width and height of the image in pixels.
Note: Always specify the width and height of an image. If width and height are not specified, the web
page might flicker while the image loads.
However, we suggest using the style attribute. It prevents styles sheets from changing the size of
images:
Example
<!DOCTYPE html>
<html>
<head>
<style>
img {
width: 100%;
}
</style>
</head>
<body>
</body>
</html>
Example
<img src="/images/html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
To point to an image on another server, you must specify an absolute (full) URL in the src attribute:
Example
<img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com">
Notes on external images: External images might be under copyright. If you do not get permission to
use it, you may be in violation of copyright laws. In addition, you cannot control external images; they
can suddenly be removed or changed.
Animated Images
HTML allows animated GIFs:
Example
<img src="programming.gif" alt="Computer Man" style="width:48px;height:48px;">
Image as a Link
To use an image as a link, put the <img> tag inside the <a> tag:
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
Image Floating
Use the CSS float property to let the image float to the right or to the left of a text:
Example
<p><img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">
The image will float to the right of the text.</p>
Lists
HTML Lists
HTML lists allow web developers to group a set of related items in list
The list items will be marked with bullets (small black circles) by default:
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Value Description
Example - Disc
<ul style="list-style-type:disc;">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Example
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
Note: A list item (<li>) can contain a new list, and other HTML elements, like images and links, etc.
Example
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Ordered HTML List - The Type Attribute
The type attribute of the <ol> tag, defines the type of the list item marker:
Type Description
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
Numbers:
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag
describes each term:
Example
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Multimedia
The HTML <video> Element
To show a video in HTML, use the <video> element:
Example
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
The HTML <audio> element is used to play an audio file on a web page.
Example
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Add muted after autoplay to let your audio file start playing automatically
YouTube Video Id
YouTube will display an id (like tgbNymZ7vqY), when you save (or play) a video.
You can use this id, and refer to your video in the HTML code.
Example
<iframe width="420" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY">
</iframe>
Inserting Tables
HTML Table
HTML table tag is used to display data in tabular form (row * column). There can be many
columns in a row.
We can create a table to display data in tabular form, using <table> element, with the help of <tr> ,
<td>, and <th> elements.
In Each table, table row is defined by <tr> tag, table header is defined by <th>, and table data is
defined by <td> tags.
HTML tables are used to manage the layout of the page e.g. header section, navigation bar, body
content, footer section etc. But it is recommended to use div tag over table to manage the layout of
the page .
<col> It is used with <colgroup> element to specify column properties for each
column.
Let's see the example of HTML table tag. It output is shown above.
1. <table>
2. <tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
3. <tr><td>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
4. <tr><td>James</td><td>William</td><td>80</td></tr>
5. <tr><td>Swati</td><td>Sironi</td><td>82</td></tr>
6. <tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
7. </table>
Syntax:
Here “href” contain the location name where the link will navigate us when we click on “MyLink”.
The location is given a name for reference and the name contain “#” at the time of creating link.
Example:
<html>
<head>
</head>
<body>
<p> Cascading Style Sheet is used for styling the web pages</p><br><br>
</body>
</html>
Syntax:
Here Pagename.html or URL is the name of the webpage or address where link will navigate on
click.
Example:
“Page1.html”
<html>
<head>
</head>
<body>
<br>
</body>
</html>
“Page2.html”
<html>
<head>
</head>
<body>
<br>
<br>
</html>
It appears within the body text, in content. It appears in website navigation as well as in the content.
It passes SEO authority from other site to your site, It passes SEO authority pages on your site, increasing the
increasing your “domain authority”. “page authority” of specific pages.
It improves the quality of web pages. It helps bots to find other web pages on your site.
It helps in increasing traffic to your website. It also helps in increasing traffic to your website.
Frames
HTML Iframe Syntax
The HTML <iframe> tag specifies an inline frame.
An inline frame is used to embed another document within the current HTML document.
Syntax
<iframe src="url" title="description"></iframe>
Tip: It is a good practice to always include a title attribute for the <iframe>. This is used by screen
readers to read out what the content of the iframe is.
Example
<iframe src="demo_iframe.htm" height="200" width="300" title="Iframe Example"></iframe>
Or you can add the style attribute and use the CSS height and width properties:
Example
<iframe src="demo_iframe.htm" style="height:200px;width:300px;" title="Iframe Example"></iframe>
To remove the border, add the style attribute and use the CSS border property:
Example
<iframe src="demo_iframe.htm" style="border:none;" title="Iframe Example"></iframe>
With CSS, you can also change the size, style and color of the iframe's border:
Example
<iframe src="demo_iframe.htm" style="border:2px solid red;" title="Iframe Example"></iframe>
The target attribute of the link must refer to the name attribute of the iframe:
Example
<iframe src="demo_iframe.htm" name="iframe_a" title="Iframe Example"></iframe>
Forms
The <form> Element
The HTML <form> element is used to create an HTML form for user input:
<form>
.
form elements
.
</form>
The <form> element is a container for different types of input elements, such as: text fields,
checkboxes, radio buttons, submit buttons, etc.
All the different form elements are covered in this chapter: HTML Form Elements.
The <input> Element
The HTML <input> element is the most used form element.
An <input> element can be displayed in many ways, depending on the type attribute.
Type Description
<input type="radio"> Displays a radio button (for selecting one of many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or more of many choices)
All the different input types are covered in this chapter: HTML Input Types.
Text Fields
The <input type="text"> defines a single-line input field for text input.
Example
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
This is how the HTML code above will be displayed in a browser:
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of an input field is 20
characters.
The <label> element is useful for screen-reader users, because the screen-reader will read out
loud the label when the user focuses on the input element.
The <label> element also helps users who have difficulty clicking on very small regions (such as
radio buttons or checkboxes) - because when the user clicks the text within the <label> element, it
toggles the radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of the <input> element to bind
them together.
Radio Buttons
The <input type="radio"> defines a radio button.
Example
<form>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
CSS
JavaScript
Checkboxes
The <input type="checkbox"> defines a checkbox.
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
Example
<form>
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label>
</form>
I have a bike
I have a car
I have a boat
The form-handler is typically a file on the server with a script for processing input data.
Example
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
This is how the HTML code above will be displayed in a browser:
First name:
John
Last name:
Doe
Submit
If the name attribute is omitted, the value of the input field will not be sent at all.
Example
This example will not submit the value of the "First name" input field:
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" value="John"><br><br>
<input type="submit" value="Submit">
</form>