Widt Unit I
Widt Unit I
When you work as a web designer, you may be tasked with creating (or working on) entire sites or
just individual pages and there is a lot to learn to be a well-rounded designer, including the
following:
➢ HTML — This is the structure of web pages, creating the foundation of all websites
➢ CSS — This is how web pages are visually styled. CSS (Cascading Style Sheets) handles
the entire look of sites, including layout, typography, colours, and more
➢ JavaScript — This governs certain behaviours on websites and can be used for a variety
of interactions and features
➢ CGI programming — CGI, and the next few entries (PHP, ASP, etc.) are all different
flavours of programming languages. Many sites do not require any of these languages, but sites
that are more feature-rich will certainly need to be coded using some of these languages
➢ SEO — Search engine optimization ensures that websites are attractive to Google and
other search engines and that people looking for the products, services, or information features
on that site can find it once they look for it online
➢ Server management — All websites need to be hosted. The management of the servers
that host those sites is an important web design skill
➢ Design — Creating the visual look and feel of websites has always been an important
aspect of the industry
➢ Speed — A successful site is one that loads quickly on a wide variety of devices,
regardless of a visitor's connection speed. Being able to tune the performance of sites is a very
valuable skill
1
2) Differences between Web Application vs Desktop Application
Deployment and up-gradation for a web- Deployment and any up-gradation/patch are
based application require deployment on a done on individual client machines separately.
single set of server machines.
Web applications can be accessed from As desktop are confined to a standalone machine,
anywhere, so there is no location so they can be only accessed from the machines
constraint. they are deployed in.
Web applications are at higher security Desktop applications, on the other hand, have
risks as they are inherently designed to better authorization and administrators have
increase accessibility. better control, hence more secure.
Web applications rely heavily on internet Desktop applications don’t require the internet
connectivity, for there operation. for their operations. Some applications just
require internet connectivity at the time of
updations.
Ex: online forms, shopping carts, word • Ex: Windows File Explorer ,Microsoft
processors, spreadsheets, video and photo Office applications,Adobe Photoshop
editing, file conversion, file scanning, and • Skype
email programs such as Gmail, Yahoo and
Popular applications include Google Apps
and Microsoft 365.
3) Introduction to HTML
Html stands for Hyper Text Mark-up Language. Html mainly use for design a client side web
pages, this is a static page it means we can only view Html page not give request and not get
response from server. Using Html pages browser get user information through form (This is
2
an Html element). Html provides so many elements (like <p>, <img>, <h1>) to design a web
page.
Hypertext: is text which contains links to other texts. The hypertext pages are interconnected
by hyperlinks, when mouse click on these link which brings you to a new webpage
Markup language: Any tag based language known as markup language, for example gml, sgml,
html, xml etc.
Tim Berners-Lee is known as father of Html. The first publicly available description of HTML was
a document called "HTML Tags", first described, on the Internet by Berners-Lee in late 1991.
HTML History
Since the early days of the World Wide Web, there have been many versions of HTML:
Year Version
Every well written HTML document begins with a basic declaration that defines what
type of document it is. This declaration is made using the !DOCTYPE tag and is to be written
at the beginning of the document. It tells the processing agent and HTML version. Sample is
shown below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML> tag:
The html tag acts as a container for the whole document. Every character in the
document should be in between the html start and end tags. The html tag can also be used to
define the language of the contained document through the "lang" attribute. The content of
the html tag is divided in two parts using the head (HTML head tag) and the body (HTML
body tag).
Every Html program contain two parts they are;.
• Head part
4
• Body part
Head part
By using head part you can provide following information related to that web page.
• Provide title of that page.
• Description about that page.
• What content inside that web page ?
• Who develop that page, (author name) ?
• Refresh that page after particular interval of time.
• When page will be expire ?
• Keyword for search that page by search engine.
Body part
Body part contains the actual information which is display on web page.
<html>
<head><title>My First Web page</title></head>
<body><p>Welcome to HTML</p></body></html>
HTML Editors
Step 1: Open Notepad (PC)
Windows 8 or later:
Open the Start Screen (the window symbol at the bottom left on your screen).
Type Notepad.
Windows 7 or earlier:
Save the file on your computer. Select File > Save as in the Notepad menu.
5
Name the file "index.htm" and set the encoding to UTF-8 (which is the preferred encoding
for HTML files).
We can use either .htm or .html as file extension. There is no difference, it is up to you.
Open the saved HTML file in your favorite browser (double click on the file, or right-click -
and choose "Open with").
5) HTML Elements
• The HTML element is everything from the start tag to the end tag:
• <tagname>Content goes here...</tagname>
• Examples of some HTML elements:
• <h1>My First Heading</h1>
• <p>My first paragraph.</p>
6
HTML elements can be nested (this means that elements can contain other elements).
HTML Attributes
6) Html Headings
The heading is a title at the head of a page or section of a book. It is very important to have
different types of headings to structure the content of the web page. Headings help search
engines to understand and index the structure of the web page. There are 6 levels of headings
in HTML: <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>.The <h1> - <h6> tags are used to mark
headings according to their importance. The <h1> tag stands for the most important heading
of the web page and the <h6> stands for the least important and smallest one.
<html>
<head>
<title>HEADINGS</title>
</head>
<body>
<h1>H1 Heading</h1>
<h2>H2 Heading</h2>
<h3>H3 Heading</h3>
<h4>H4 Heading</h4>
<h5>H5 Heading</h5>
<h6>H6 Heading</h6>
</body>
</html>
HTML headings highlight important topics and the document structure, thus improving user
engagement.
Use only one <h1> tag on any web page. The tag must describe what your page is about and
also contain a keyword to improve rankings in Google.Search Engines use headings for
indexing the structure and content of the webpage.
7
7) HTML Paragraphs
The HTML <p> element defines a paragraph.
A paragraph always starts on a new line, and browsers automatically add some white space
(a margin) before and after a paragraph.
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
HTML Horizontal Rules
<hr> (Horizontal Rules) tag are used for to create a horizontal line on html page. <hr> are
used for separate the content on html page.
Attributes:
SIZE Height of the rule in pixels
WIDTH Width of the rule in pixels or percentage of screen width
ALIGN Aligns the line (Left, Center, Right)
COLOR Sets a color for the rule
<html>
<body>
</body>
</html>
8
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it
preserves both spaces and line breaks:
<html>
<body>
<p>The pre tag preserves both spaces and line breaks:</p>
<pre>
My Bonnie lies over the ocean.
8) HTML Styles
The HTML style attribute is used to add styles to an element, such as color, font, size, and
more. Setting the style of an HTML element, can be done with the style attribute.
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
The CSS color property defines the text color for an HTML element:
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
The CSS font-size property defines the text size for an HTML element:
HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA, or
HSLA values.
Color Names
9
In HTML, a color can be specified by using a color name:
Color Values
In HTML, colors can also be specified using RGB values, HEX values, HSL values, RGBA
values, and HSLA values.
Each parameter (red, green, and blue) defines the intensity of the color with a value
between 0 and 255.
This means that there are 256 x 256 x 256 = 16777216 possible colors!
RGBA color values are an extension of RGB color values with an Alpha channel - which
specifies the opacity for a color.
The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent
at all):
Sy:- #rrggbb
Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00 and ff (same as
decimal 0-255).
For example, #ff0000 is displayed as red, because red is set to its highest value (ff), and the
other two (green and blue) are set to 00.
Ex: #ff6347
10
HSL Color Values
In HTML, a color can be specified using hue, saturation, and lightness (HSL) in the form:
Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue.
Saturation is a percentage value. 0% means a shade of gray, and 100% is the full color.
<html>
<body>
<p>Same as color name "Tomato":</p>
<h1 style="background-color:rgb(255, 99, 71);">rgb(255, 99, 71)</h1>
<h1 style="background-color:#ff6347;">#ff6347</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">hsl(9, 100%, 64%)</h1>
<p>Same as color name "Tomato", but 50% transparent:</p>
<h1 style="background-color:rgba(255, 99, 71, 0.5);">rgba(255, 99, 71, 0.5)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">hsla(9, 100%, 64%, 0.5)</h1>
<p>In addition to the predefined color names, colors can be specified using RGB, HEX,
HSL, or even transparent colors using RGBA or HSLA color values.</p>
</body>
</html>
10) Html Formatting
In HTML, a number of elements are used to format text. The formatting tags are divided into
two groups: physical tags, that are used to style the text (visual appearance of the text)
and logical or semantic tags that add semantic value to the text parts (e. g., inform search
engines for which keywords a web page should be ranked).
The <b> tag is a physical tag that stands for bold text, whereas the <strong> tag being a
logical tag is used to emphasize the importance of the text.
The <i> and <em> tags define italic text. The <i> tag is only responsible for visual
appearance of the enclosed text, without any extra importance. The <em> tag defines
emphasized text, with added semantic importance.
<pre> :
The <pre> tag is used to define preformatted text. The browsers render the enclosed text
with white spaces and line breaks.
11
<mark> :
The <mark> tag is used to present a part of text in one document as marked or highlighted
for reference purposes.
<small> :
The <small> tag decreases the text font size by one size smaller than a document's base font
size (from medium to small, or from x-large to large). The tag usually contains the items of
secondary importance such as copyright notices, side comments, or legal notices.
<big>
The <del> tag specifies a part of the text that was deleted from the document. Browsers
display this text as a strikethrough.
The <ins> tag defines the text that has been inserted (added) to the document. The content
of the tag is displayed as underlined.
The <u> tag specifies text that is stylistically different from normal text, i.e. words or
fragments of text that need to be presented differently. This could be misspelled words or
proper nouns in Chinese.
The <sub> defines subscript texts. Subscript text is under the baseline of other symbols of
the line and has smaller font. The <sup> tag defines superscript, that is set slightly above the
normal line of type and is relatively smaller than the rest of the text. The baseline passes
through upper or lower edge of the symbols.
<dfn> :
The <dfn> tag is used to define the term, that is mentioned for the first time. The content of
the tag is displayed in italic.
<p>, <br> :
The <p> tag defines the paragraph. Browsers automatically add 1em margin before and
after each paragraph.
The <br> tag inserts a single line break. Unlike the <p> tag an empty indent is not added
before the line.
Monospaced Font:
12
If you want that each letter has the same width then you should write the content within
<tt>.............</tt> element.
EX-1
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>We use the <strong> tag to highlight the importance <strong> of this part of the
text</strong>.</p>
<p>The <b> tag is a physical tag that stands for <b>bold text</b>.</p>
<p>The important part of the text is defined <em> in italic</em>.</p>
<p><i>Lorem ipsum</i>, or lipsum as it is sometimes known, is dummy text used in
laying out print, graphic or web designs. </p>
<pre>Spaces
and line breaks
within this element
are shown as typed.
</pre>
<p>Learn the HyperText Markup Language on <mark>W3Docs.com</mark>.</p>
<p>The interest rate is only 10%*</p>
<small>* per day</small> /
<p> She likes <del>violets</del> snowdrops․</p>
<p><s>I am studying in high school.</s></p>
<p>I am studying in a university.</p>
<p>She likes <del>violets</del> <ins>snowdrops</ins>․</p>
<p>Here we used <u>the <u> tag</u>.</p>
<p>The formula of water is H<sub>2</sub>O, and the formula of alcohol is
C<sub>2</sub>H<sub>5</sub>ОН </p>
<p>E = mc<sup>2</sup>, where E — kinetic energy, m — mass, c — the speed of light.
</p>
<p><dfn>HTML</dfn> (HyperText Markup Language ) — The standardized markup
language for documents on the World Wide Web. Most web pages contain a description of
the markup in the language HTML</p>
<h1>How to use the <br> tag</h1>
13
<p> We can insert the <br /> tag inside the paragraph, <br /> to transfer a part of
the text to another line if necessary.</p>
</body>
</html>
EX-2
<html>
<head>
<title>HTML Formatting Tags</title>
</head>
<body bgcolor="cyan">
<big><h1 align="center">FORMATTING TAGS</h1></big>
<u>MATHEMATICS</u>
<p><i>It is king of all sciences</i></p>
<u><i>Fromulae:</i></u>
<br>
<small><i>FOLLOWING ARE FEW FORMULAS IN MATHEMATICS</i></small><br>
<ol type="1">
<li>(a+b)<sup>2</sup>=a<sup>2</sup>+b<sup>2</sup>
+2ab</li>
<li>log<sub>e</sub>e<sup>x</sup>=x</li>
</ol>
<hr size="4px" color="red" WIDTH="40%" align="left">
<u><big>STRIKE</big></u>
<p>In onlone shopping we can see the usage of the strike tag.</p>
example:Rs<strike>400</strike>
</body>
</html>
The HTML <blockquote> element defines a section that is quoted from another source.
<abbr>
The HTML <abbr> tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.",
"Dr.", "ASAP", "ATM".
14
Use the global title attribute to show the description for the abbreviation/acronym when
you mouse over the element.
<address>
The HTML <address> tag defines the contact information for the author/owner of a
document or an article.
The contact information can be an email address, URL, physical address, phone number,
social media handle, etc.
The text in the <address> element usually renders in italic, and browsers will always add a
line break before and after the <address> element.
<bdo>
The HTML <bdo> tag is used to override the current text direction
dir ltr Required. Specifies the text direction of the text inside the <bdo> element
rtl
<html>
<body>
<p>Browsers usually indent blockquote elements.</p>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For nearly 60 years, WWF has been protecting the future of nature. The world's leading
conservation organization, WWF works in 100 countries and is supported by more than one
million members in the United States and close to five million globally.
</blockquote>
<p>Browsers usually insert quotation marks around the q element.</p>
<p>WWF's goal is to: <q>Build a future where people live in harmony with
nature.</q></p>
<p>The <abbr title="World Health Organization">WHO</abbr> was founded in
1948.</p>
<p>Marking up abbreviations can give useful information to browsers, translation systems
and search-engines.</p>
<p>The HTML address element defines contact information (author/owner) of a document
or article.</p>
<address>
Written by John Doe.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
15
<bdo dir="rtl">This line will be written from right to left</bdo>
</body>
</html>
Html Comment
Comment is nothing but it is a statement which is not display on browser window. It is
useful to understand the which code is written for what purpose. Comment tags <!-- and -
-> are use for comment on html page.
Syntax
<! Comments>
</body>
</html>
16
13) Table:
Using table we arrange data in the form of row and column. To create a table in html
use <table>tag. Complete table are design by using below tags.
• Table are divided into table row using <tr> tag.
• Table row are again dived into table data using <td> tag.
• Table row also divide into table heading using <th> tag.
The HTML <table> tag also supports the following additional attributes −
border pixels Deprecated − Specifies the border width. A value of "0" means no
border.
cellpadding pixels or % Deprecated − Specifies the space between the cell borders and their
contents.
17
• colspan : This attribute defines the number of columns. It is used inside <td> tag.
• rowspan : This attribute defines the number of row. It is used inside <td> tag.
• id : This attribute are used for provide unique id for table
HTML Table Tags
<html>
<body>
<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<tr>
<td>row 1, cell 1</td> <td>row 1,
cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
18
</table>
<h4>Vertical headers:</h4>
<table border="1">
<tr>
<th>First Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 777 1854</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 777 1855</td>
</tr>
</table> </body>
</html>
Output:
TYPE
1 1,2,3, …… , a a, b, c, …… ,A A, B, C, …… , i, ii, iii, ……
I I, II, III, ……
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h3>A numbered list:</h3>
<ol>
<li>Peach</li>
19
<li>Apricot</li>
<li>Banana</li>
<li>Strawberry</li>
</ol>
<h3>An alphabetized list:</h3>
<ol type="A">
<li>Peach</li>
<li>Apricot</li>
<li>Banana</li>
<li>Strawberry</li>
</ol>
<h3>An alphabetized list (lowercase letters):</h3>
<ol type="a">
<li>Peach</li>
<li>Apricot</li>
<li>Banana</li>
<li>Strawberry</li>
</ol>
<h3>A numbered list (Roman numerals):</h3>
<ol type="I">
<li>Peach</li>
<li>Apricot</li>
<li>Banana</li>
<li>Strawberry</li>
</ol>
<h3>A numbered list (lowercase Roman numerals):</h3>
<ol type="i">
<li>Peach</li>
<li>Apricot</li>
<li>Banana</li>
<li>Strawberry</li>
</ol>
</body>
</html>
UL : Unordered List.
The items in unordered lists are marked with bullets (small black circles) by default.Items
in this list start with a list mark such as a bullet. Browsers will usually change the list mark
in nested lists.
20
<html>
<head>
</head>
<body>
<ul type="circle">
<li>List item</li>
<li>List item</li>
</ul>
<ul type="square">
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ul>
</body>
</html>
This kind of list is different from the others. Each item in a DL consists of one or more
Definition Terms (DT elements), followed by one or more Definition Description
(DD elements).
HTML
Hyper Text Markup Language
DOG
A human’s best friend!
<html>
<head>
</head>
21
<body>
<h1>Description Lists:</h1>
<dl>
<dt>Tea</dt>
<dt>Juice</dt>
</dl>
</body>
</html>
15 ) Block-level Elements
A block-level element is an HTML element that starts on a new line and takes up the full
available width of its parent element’s horizontal space. This kind of element creates blocks
of content (paragraphs, page divisions). The majority of HTML elements are block-level
elements.
Block-level elements are used within the body of an HTML document and can contain inline
elements, or other block-level elements.
Mostly <div> are used for divide complete page into section like footer, header, left, right
section.
Example
<html>
<body>
<div style="background:#00FF99">
<h3>Heading inside a div</h3>
<p>Text inside a div element.</p>
</div>
22
<div style="background:#FFCAFF">
<h3>Heading inside a div</h3>
<p>Text inside a div.</p>
</div>
<div style="background:#66FFFF">
<h3>Heading inside a div</h3>
<p>Text inside a div.</p>
</div>
</body>
</html>
Inline Elements
Unlike block-level elements, inline elements do not start on a new line. They begin within a
line and only take up as much width as it is necessary. Inline elements are included as a part
of the main text.
Inline elements commonly contain other inline elements, or they can be empty.
<span> Tag
The <span> tag is a generic inline container that groups elements primarily for styling
purposes. The <span> tag, as well as <div> tag are empty containers. The <div> tag groups
block level elements, whereas the <span> groups inline elements. The content hooked in the
<span> element, can be styled with CSS, or manipulated with JavaScript.
Here are some examples of the HTML <span> tag usage:
Highlight a part of a text with color, define a background color or background image for it.
Change the font of separate words or phrases.
• Apply scripts to certain parts of the text, e.g., highlight the code syntax.
The <span> tag comes in pairs. The content is written between the opening (<span>) and
closing (</span>) tags.
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>My cat has <span style="color:#8ebf42;">green</span> eyes.</p>
</body>
</html>
Marquee tag
Marquee tag are used for display the moving content on the web browser. Marquee tag
contain the following attribute.
• Direction: To specify direction of moving content like left, right, up, down.
• Scroll amount: To specify the speed of the content.
23
• Loop: To specify how many time that text has to move on the browser window.
• Behavior: To specify the style to the moving content. It have attribute scroll, alternate,
slide.
Example
<html>
<body>
<marquee direction="left" scrollamount="10" loop="5"
behavior="slide" >My first web page</marquee>
</body>
</html>
With CSS, you can control the color, font, the size of text, the spacing between elements,
how elements are positioned and laid out, what background images or background colors
are to be used, different displays for different devices and screen sizes, and much more
Inline CSS
</body>
</html>
Internal CSS
An internal CSS is used to define a style for a single HTML page.
An internal CSS is defined in the <head> section of an HTML page, within a <style> element.
24
The following example sets the text color of ALL the <h1> elements (on that page) to blue,
and the text color of ALL the <p> elements to red. In addition, the page will be displayed with
a "powderblue" background color:
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
External CSS
An external style sheet is used to define the style for many HTML pages.
To use an external style sheet, add a link to it in the <head> section of each HTML
page:
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
The external style sheet can be written in any text editor. The file must not contain
any HTML code, and must be saved with a .css extension.
styles.css":
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p{
color: red;
}
SP ) Html Hyperlinks:
25
Websites contain different types of links that take you directly to other pages or allow to navigate to a
particular part of the page. The links in HTML are called hyperlinks. They are defined using
the <a> tag
Hyperlinks are used to create links that allow the users to navigate from one page to another.
Syntax
The <a> tag comes in pairs, the opening <a> tells where the link should start and the closing </a>
indicates where the link ends.
To create a hyperlink, you should use the <a> tag and href attribute, the value of which is the URL, or
location, where the link is pointing to.
Target Attribute
Target Value Description
Image as Link
In html you can give image as a link, when click on image linked page will be
open. In below example image link is provided.
Example
26
<html>
<body>
<a href="/html/index" target="_top"><img src="files/sublogo.png"
target="_blank"></a>
</body>
</html>
16) Frames
HTML frames are used to divide your browser window into multiple sections
where each section can load a separate HTML document. A collection of frames
in the browser window is known as a frameset. The window is divided into frames
in a similar way the tables are organized: into rows and columns.
The disadvantages of using frames are:
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag. The
<frameset> tag defines, how to divide the window into frames. The rows
attribute of <frameset> tag defines horizontal frames and cols attribute defines
vertical frames. Each frame is indicated by <frame> tag and it defines which
HTML document shall open into the frame.
<frameset> Tag Attributes
cols
Specifies how many columns are contained in the frameset and the size of each
column.
rows
28
This attribute works just like the cols attribute and takes the same values, but it
is used to specify the rows in the frameset. For example, to create two horizontal
frames, use rows = "10%, 90%".
<frame> Tag Attributes
Src
This attribute is used to give the file name that should be loaded in the frame.
Its value can be any URL. For example, src = "/html/top_frame.htm" will load
an HTML file available in html directory.
name
This attribute allows you to give a name to a frame. It is used to indicate which
frame a document should be loaded into.
Frame's name and target attributes
One of the most popular uses of frames is to place navigation bars in one frame
and then load main pages into a separate frame.
The targetattribute can also take one of the following values
_self
Loads the page into the current frame.
_blank
Loads a page into a new browser window. Opening a new window.
_parent
Loads the page into the parent window, which in the case of a single frameset
is the main browser window.
_top
Loads the page into the browser window, replacing any current frames.
targetframe
Loads the page into a named targetframe.
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows = "10%,80%,10%">
<frame name = "top" src = "/html/top_frame.htm" />
29
<frame name = "main" src = "/html/main_frame.htm" />
<frame name = "bottom" src = "/html/bottom_frame.htm" />
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
30
HTML has several semantic elements that define the different parts of a web page:
There are four different techniques to create multicolumn layouts. Each technique has its
pros and cons:
• CSS framework
• CSS float property
• CSS flexbox
• CSS grid
CSS Frameworks
If you want to create your layout fast, you can use a CSS framework, like W3.CSS or Bootstrap.
It is common to do entire web layouts using the CSS float property. Float is easy to learn -
you just need to remember how the float and clear properties
work. Disadvantages: Floating elements are tied to the document flow, which may harm
the flexibility.
CSS Flexbox Layout
Use of flexbox ensures that elements behave predictably when the page layout must
accommodate different screen sizes and different display devices.
The CSS Grid Layout Module offers a grid-based layout system, with rows and columns,
making it easier to design web pages without having to use floats and positioning.
<!DOCTYPE html>
<html lang="en">
31
<head>
<title>CSS Template</title>
<meta charset="utf-8">
<style>
*{
box-sizing: border-box;
body {
header {
background-color: #666;
padding: 30px;
text-align: center;
font-size: 35px;
color: white;
nav {
float: left;
width: 30%;
background: #ccc;
padding: 20px;
32
nav ul {
list-style-type: none;
padding: 0;
article {
float: left;
padding: 20px;
width: 70%;
background-color: #f1f1f1;
section::after {
content: "";
display: table;
clear: both;
footer {
background-color: #777;
padding: 10px;
text-align: center;
color: white;
/* Responsive layout - makes the two columns/boxes stack on top of each other instead of
next to each other, on small screens */
nav, article {
width: 100%;
33
height: auto;
</style>
</head>
<body>
<p>In this example, we have created a header, two columns/boxes and a footer. On smaller
screens, the columns will stack on top of each other.</p>
<p>Resize the browser window to see the responsive effect (you will learn more about this
in our next chapter - HTML Responsive.)</p>
<header>
<h2>Cities</h2>
</header>
<section>
<nav>
<ul>
<li><a href="#">London</a></li>
<li><a href="#">Paris</a></li>
<li><a href="#">Tokyo</a></li>
</ul>
</nav>
<article>
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United
Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has been a major settlement for two
millennia, its history going back to its founding by the Romans, who named it
Londinium.</p>
</article>
</section>
34
<footer>
<p>Footer</p>
</footer>
</body>
</html>
</body>
</html>
35
Responsive web design is about creating web pages that look good on all devices!A responsive
web design will automatically adjust for different screen sizes and viewports. Responsive Web
Design is about using HTML and CSS to automatically resize, hide, shrink, or enlarge, a
website, to make it look good on all devices (desktops, tablets, and phones):
The HTML <picture> element allows you to define different images for different browser
window sizes.
<body>
<h2>Show Different Images Depending on Browser Width</h2>
<p>Resize the browser width and the image will change at 600px and 1500px.</p>
<picture>
<source srcset="img_smallflower.jpg" media="(max-width: 600px)">
<source srcset="img_flowers.jpg" media="(max-width: 1500px)">
<source srcset="flowers.jpg">
<img src="img_flowers.jpg" alt="Flowers" style="width:auto;">
</picture>
</body>
36
Responsive Text Size
The text size can be set with a "vw" unit, which means the "viewport width".
That way the text size will follow the size of the browser window:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1 style="font-size:10vw;">Responsive Text</h1>
<p style="font-size:5vw;">Resize the browser window to see how the text size scales.</p>
<p style="font-size:5vw;">Use the "vw" unit when sizing the text. 10vw will set the size to
10% of the viewport width.</p>
<p>Viewport is the browser window size. 1vw = 1% of viewport width. If the viewport is
50cm wide, 1vw is 0.5cm.</p>
</body>
</html>
Bootstrap
Another popular CSS framework is Bootstrap. Bootstrap uses HTML, CSS and jQuery to
make responsive web pages.
37