HTML and Css
HTML and Css
AND HTML
KS UNIT-3
Client/Server Architecture
Server
Web Client/ Web Server
Web Server
Web server receives a client request, process the
Web Client
A web client is an application that communicates with a
web server, using Hypertext Transfer Protocol (HTTP)
Web browser is a software that acts as a web client.
Clients & Servers Example
Clients (Browser) Servers
Internet Explorer Apache
Firefox IIS Web Server.
Mozilla Litespeed server
Netscape Google Web
Opera server(GWS)
Amaya Oracle iplanet
AOL WebServer
MSN
4
Web Essentials
“Web”- short for “World Wide Web”
A web page is a simple text file written in a markup language
(called HTML)
A website is a group of HTML files that are stored on a
hosting computer which is permanently connected to the
internet
URL - Uniform Resource Locator - used to indicate a
resource on the Internet
Home page -The main page on a particular Web site or index
page
How the browser interacts with the
servers ?
User enters the URL(Uniform Resource Locator) of the
website or file. The Browser then requests the DNS(DOMAIN
NAME SYSTEM) Server.
DNS Server lookup for the address of the WEB Server.
DNS Server responds with the IP address of the WEB Server.
Browser sends over an HTTP/HTTPS request to WEB
Server’s IP (provided by DNS server).
Server sends over the necessary files of the website.
Browser then renders the files and the website is displayed.
This rendering is done with the help of DOM (Document
Object Model) interpreter, CSS interpreter and JS
Engine collectively known as the JIT or (Just in Time)
Compilers.
Domain Name, URL’s and IPs
Uniform Resource Locator (URL):
http://www.microsoft.com/faqs.html
protocol pathname
http://www.chicagosymphony.org/civicconcerts/index.html
Domain name
filename
http://www.kongu.edu/department/CSE/index.html
Markup Languages
HTML, XHTML, XML, XSLT, etc....
Cascading Style Sheets (CSS)
Scripting languages
Client-side: javascript, VBScript
Server-side: perl, NodeJS, php, JSP, Servlet etc....
Web creation and editing software
Notepad, FrontPage, Flash, Site Builder etc..
Frameworks
Angular JS
React JS
Web Page Vs Website
A Web page is a A collection of related
document in the World web pages located
Wide Web that is under a single domain
identified uniquely by name.
a uniform resource Called as Web Sites
locator (URL) and is
displayed in a web
browser
Called as Pages
HTML-Hyper Text Markup Language
<Body>
< / HTML>
HTML – Basic Structure
<html>
<body>
<! - - your web page content and markup - ->
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Description
The <!DOCTYPE html> declaration defines this
document to be HTML5
The text between <html> and </html> describes an
HTML document
The text between <head> and </head> provides
information about the document
The text between <title> and </title> provides a title for
the document
The text between <body> and </body> describes the
visible page content
The text between <h1> and </h1> describes a heading
The text between <p> and </p> describes a paragraph
HTML - Comment lines
Comments are not displayed in the browser
Starts with <!--
Ends with -->
Example:
<!--This is a comment. -->
HTML Tags
HTML tags are keywords (tag names) surrounded
by angle brackets:
Syntax: <tagname>content goes here...</tagname>
HTML tags normally come in pairs like <p> and
</p>
The first tag in a pair is the start tag, the second
tag is the end tag
The end tag is written like the start tag, but with a
forward slash inserted before the tag name
HTML Heading Tag
HTML headings are defined with the <h1> to <h6>
tags
<h1> defines the most important heading
<h6> defines the least important heading
Example:
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
HTML ATTRIBUTES
<BODY bgcolor=“blue”>
<BODY bgcolor=“rgb(255,0,0)” >
<BODY bgcolor=“#0000FF”>
https://htmlcolorcodes.com/
24
HTML -Colors
Color is the combination of red, green and blue
color = “red” (Browser compatibility issues)
color=“rgb(122,255,0)”
color = “#FF0000”
Red Blue
Green
25
HTML Links- anchor tag
HTML links are defined with the anchor tag<a>
Example
Test.html
<a href="http://www.kongu.ac.in"> kongu</a>
Test.html
HTML Links
Test.html
<body>
<a href=“bio.html”> Read my BIO </a>
<body>
bio.html
<body>
Welcome to web Page
</body>
<anchor > - Target attribute value
Target=“value”
Value can be
Hypertext links
<a href=“bio.html” target=“_blank” > BiO DATA </a>
Creates new window for the page
30
HTML Images
HTML images are defined with the <img> tag
The source file (src), alternative text (alt), and size
be displayed
Example:
<html>
<body>
<p title="Web"> The three primary colors, <hr> red, green and blue, <br> are made </p>
</body>
</html>
HTML Display
With HTML, we cannot change the output by adding
extra spaces or extra lines in your HTML code.
The browser will remove any extra spaces and extra
lines when the page is displayed
Ex:
<p>
This paragraph
contains a lot of spaces
in the source code,
but the browser
ignores it.
</p>
HTML <pre> Element
The HTML <pre> element defines preformatted
text.
The text inside a <pre> element is displayed in a
fixed-width font (usually Courier), and it preserves
both spaces and line breaks
<pre> </pre>
Ex: Poem – line by line
HTML Formatting Elements
HTML also defines special elements for defining text with a special
meaning.
HTML uses elements like <b> and <i> for formatting output, like
bold or italic text
<b> - Bold text
<strong> - Important text
<i> - Italic text
<em> - Emphasized text
<mark> - Marked text
<small> - Small text
<del> - Deleted text
<ins> - Inserted text
<sub> - Subscript text
<sup> - Superscript text
Output of Formatting tags
HTML Lists
Unordered List
Item
Item
Item
Item
Ordered List
1. Item
2. Item
3. Item
4. Item
HTML Lists
44
Unordered HTML List- type attributes
An unordered list starts with the <ul> tag
Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles) by default
Value Description
Sets the list item marker to a
disc
bullet (default)
Sets the list item marker to a
circle
circle
Sets the list item marker to a
square
square
The list items will not be
none
marked
Ordered HTML List type attributes
An ordered list starts with the <ol> tag
Each list item starts with the <li> tag
The list items will be marked with numbers by default
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
HTML Elements-Ordered List
How to design a nested list?
1. Coffee
2. Tea
o Black tea
o Green tea
3. Milk
Nested HTML Lists
List can be nested - lists inside lists
Example:
<ol>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ol>
HTML Tables
An HTML table is defined with the <table> tag.
Each table row is defined with the <tr> tag
A table header is defined with the <th> tag. By
default, table headings are bold and centered.
A table data/cell is defined with the <td> tag
HTML Table tags
HTML TABLES
<table>
Style, border….
<tr> --- Table row
<td> --- Table data
Attribute— rowspan, colspan
text, images, lists, other tables, etc.
<tr>
<td>Orange</td>
<td>50</td>
</tr>
</tbody>
COLSPAN
Cell that spans two columns (Merged tow columns)
<tfoot>
<tr>
<th colspan="3">Total:150</th>
</tr>
</tfoot
Colgroup
Set the background color of particular columns with the <colgroup> and <col> tags
<table border="1">
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
</table>
56
CELL PADING vs CELL SPACING
58
HTML-Internal Linking[bookmarking]
Used to create linking or book marking within a page
Page should exceed more than one page
Example:
<body>
<h1 id = "books">my favourite books</h1>
<p><a href = "#languages">Go to Favorite languages</a></p>
<ul>
……………..
<audio controls>
<source src=“sample.mp3" type="audio/mp3">
</audio>
Media Tags - <video>
The HTML <video> element is used to play an
video file on a web page.
The controls attribute adds video controls, like
play, pause, and volume.
Autoplay – (does not supported in all browser)
<label>
<textarea>
<button>
<select>
Syntax:
<form> Form Content... </form>
label
The <label> tag defines a label for all elements
The for attribute of <label> must be equal to the id
attribute of the related element to bind them
together. A label can also be bound to an element
by placing the element inside the <label> element.
Input tag
The <input> tag specifies an input field where the user
can enter data
Syntax
<input type = "value" .... />
Attributes:
Value :The initial value of the control used for all input tag
Type:Type of form control
Name:Name of the form control. Submitted with the form as part of
a name/value pair
Minlength:Minimum length (number of characters) of value. Used in
text, search, email, password
Size:Size of the control -Used in text, search, email, password
Checked:Whether the command or control is checked -Used in
checkbox, radio
Input tag types
Type Description Basic Examples
◻ example
<div>
<p>Hello! This is a paragraph.</p>
</div>
<Span>
◻ an inline container used to mark up a part of a text, or a
part of a document
◻ easily styled by CSS or manipulated with JavaScript using
the class or id attribute
◻ much like the <div> element, but <div> is a block-level
element and <span> is an inline element.
Example
<p>this is a <span>span tag span></p>
Semantic elements
Semantic elements have meaningful names which
tells about type of content. For example header,
footer, table, … etc.
Examples of non-semantic elements:
<section>
It represents the section of the document.
<article>
The <article> element specifies independent, self-contained
content. It may contain User comments, Product cards,
Newspaper articles
Semantic tags
<main>
This specifies the main page content and should be
unique.
<aside>
The <aside> element defines some content aside from
the content it is placed in (like a sidebar).
<footer>
The <footer> element defines a footer for a document or
section. It may contain authorship information
copyright information, contact information, sitemap etc
CASCADING STYLE SHEET
CSS
Html
Used for marking up information to be rendered in a
browser.
CSS- Cascading Style Sheet
1. Specifies the presentation of elements on a web
page (e.g., fonts, spacing, sizes, colors, positioning)
separately from the document’s structure and content
2. CSS can be added to HTML documents in 3 ways
a) Inline b)Embedded or internal c) External
Introduction
or in other media
Colors, fonts, alignment, borders, backgrounds, spacing,
margins, etc…
It can control the layout of multiple web pages all at once
Advantage
◻ Reusability
◻ Separate the content and presentation
CSS vs. just HTML
88
HTML
<body bgcolor="#FF0000">
CSS
body {background-color: #FF0000;}
How to write CSS?
90
◻ Selector
⦁ HTML element tags
(examples: p, h2, body, img, table)
⦁ class and ID names
◻ Property (examples: color, font-size)
◻ Value (examples: red, 14pt)
Basic Structure of a Style
◻ Each definition contains:
⦁ A property
⦁ A colon
⦁ A value
⦁ A semicolon to separate two or more
values
⦁ Can include one or more values
◻ h1 {font-size:12pt; color:red}
Example:
p{
color: red;
text-align: center;
}
body {
background-color: lightblue;
}
Type of CSS
section
External - by using a <link> element to link to an
Saves Time
◻ can change the look of an entire website by changing
just one file
CSS Inheritance: - which style prevails when
several are present?
Color
The color property is used to set the color of a text. The color
is specified by:
Example:
a color name - "red"
h1 {
a HEX value - "#ff0000"
text-transform:
This property controls the capitalization of text Specifies the
kind of text decoration to be used (underline, overline,
etc.)
text-transform: capitalize|uppercase|lowercase
Example: h2 { text-transform: lowercase;
}
font
font-family:
.p1 {
font-family: "Times New Roman”;
font-size: 30px;
}
Backgrounds
(xpos ypos)
or
<Div> & <Span> tag
◻ HTML Block (DIV) and Inline (SPAN) Elements
◻ <DIV>
◻ defines a division or a section in an HTML document
◻ used as a container for HTML elements - which is then styled with CSS or
manipulated with JavaScript
◻ easily styled by using the class or id attribute
◻ <Span>
◻ an inline container used to mark up a part of a text, or a part of a
document
◻ easily styled by CSS or manipulated with JavaScript using the class or id
attribute
◻ much like the <div> element, but <div> is a block-level element
and <span> is an inline element.
HTML Block and Inline Elements
Block Elements Inline Elements
<a>
<address> <input>
<hr> <abbr>
<kbd>
<blockquote> <li> <acronym>
<label>
<div> <b> <map>
<nav> <bdo> <object>
<fieldset> <ol> <br> <output>
<figcaption> <p> <button> <q>
<cite> <script>
<figure> <pre>
<code> <select>
<footer> <section> <dfn> <small>
<form> <table> <em> <span>
<tfoot> <i> <strong>
<h1>-<h6> <img> <textarea>
<ul>
<header> <sub> <time>
<video> <sup>
HTML <div> Tag
HTML <span> Tag
CSS Box Model
❏ All HTML elements can be considered as boxes
❏ CSS box model is essentially a box that wraps around every
HTML element.
❏ It consists of
❏ Content - The content of the box, where text and images
appear
❏ Padding - Clears an area around the content. The padding
is transparent
❏ Border - A border that goes around the padding and
content
❏ Margin - Clears an area outside the border. The margin is
transparent
BOX MODEL
BOX- Margin and Padding
MARGIN PROPERTY
CSS margin properties are used to create
space around elements, outside of any
defined borders.
margin:10px
margin-top:5px
margin-right:10px
margin-bottom:10px
margin-left:10px
PADDING PROPERTY
Shorthand property
padding: 2px ;
padding-left::2px ;
padding-right:2px ;
padding-bottom:2px;
padding-top:2px ;
BORDER PROPERTY
Shorthand property
border: 2px solid pink