html css
html css
WEB TECHNOLOGIES
AUE-CSC 204
1
Course Outline
2 2
Learning Objectives
1. Understand key web technologies: Identify and describe the key technologies
and programming models of the web.
2. Client-side technologies: Explain and apply client-side technologies such as
HTML, CSS, and JavaScript.
3. Content formats and creation: Understand and create content using client-side
technologies.
4. Server-side technologies: Describe and explain server-side technologies such as
web and application servers, database back ends, and client-server
programming models.
5. Communication protocols: Understand and explain communication protocols
such as HTTP and TCP/IP.
6. Basic database-driven application development: Develop a basic database-
driven application using a familiar application framework (time permitting).
3 3
1: Internet Fundamentals & HTML 2: HTML Deep Dive
Basics • HTML5 semantic elements
• Course introduction and overview • Forms and input types
• How the internet works • Tables and lists
• Introduction to client-server • Media elements (images, audio,
architecture video)
• Basic HTML structure and elements • Best practices for HTML structure
• Creating your first webpage • Lab: Create a structured content
• Lab: Build a simple personal page with various HTML elements
webpage using HTML
4 4
3. Introduction to CSS 4. CSS Layout & Responsiveness
• CSS syntax and selectors • Display properties
• Box model • Positioning
• Colors, typography, and basic styling • Flexbox
• Linking CSS to HTML • Media queries and responsive design
• CSS specificity • CSS Grid introduction
• Lab: Style the previously created • Lab: Make your website responsive
HTML pages across different screen sizes
5 5
5. JavaScript Fundamentals 6. JavaScript & DOM
• Introduction to JavaScript • Events and event handling
• Variables, data types, and operators • More DOM manipulation
• Control structures • Forms validation
• Functions • Local storage
• Basic DOM manipulation • JSON basics
• Lab: Add simple interactivity to • Lab: Create an interactive form with
your website validation
6 6
7. Internet Protocols & Web Security 8. Introduction to Backend
• HTTP/HTTPS protocols Development
• TCP/IP overview • Server-side concepts
• Web security basics • Introduction to APIs
• CORS and same-origin policy • RESTful services
• Common security threats • HTTP methods (GET, POST, PUT,
DELETE)
7 7
9. Databases & Storage
• Database concepts
• SQL vs NoSQL
• Basic database operations
• Connecting to a database
8 8
What is Web Technology?
9 9
Web technology is the collection of tools, languages, and frameworks used to create and
maintain websites and web applications. It allows users to interact with information on the
internet.
Components of web technology
• Web browsers: Software that displays web pages and retrieves information from the
internet
• Web servers: Systems that store, process, and deliver web pages to users
• Hypertext Markup Language (HTML): The standard language for creating web pages
• Cascading Style Sheets (CSS): A language that describes how HTML documents are
presented
• JavaScript: A programming language that creates interactive effects and dynamic content
• Databases: Systems that store, retrieve, and query data
1010
1111
1212
Web Essentials
1313
CLIENTS
A "client" refers to any software application that requests services from another
application (usually a server). It can be a software application, a computer, or any
other device that can connect to a network.
Clients initiate communication with servers, send requests, and receive responses.
They typically process and display the information received from the server.
Examples:
•A desktop email application like Microsoft Outlook is a client that requests
emails from a mail server.
•A video game console is a client that connects to game servers to play online
games.
•A mobile app that fetches data from a server is a client.
1414
WEB CLIENT
•A web client is a specific type of client that uses a web browser to interact with
web servers. It's essentially a program that can display web pages and interact with
web applications.
•Function: Web clients send HTTP requests to web servers, receive HTML, CSS, and
JavaScript code, and render it to display web pages. They also handle user
interactions with web pages, such as clicking links or submitting forms.
•Examples:
•Popular web browsers like Google Chrome, Mozilla Firefox, Safari, and
Microsoft Edge are all web clients.
•Any application that displays web content or interacts with web services
through a browser is considered a web client.
1515
KEY DIFFERENCES
Feature Client Web Client
General term for any program or Specific type of client using a
Type
device requesting services web browser
Can use various protocols (e.g.,
Communication Primarily uses HTTP or HTTPS
TCP/IP, SMTP)
Can have a dedicated user interface Relies on a web browser for
Interface
or run in the background user interaction
Typically, does not require
May require installation on the
Installation installation, accessed through a
user's device
browser
Updates may need to be manually Updates are usually handled
Updates
installed automatically by the browser
1616
SERVER
1717
WEB SERVER
•A web server is a specific type of server that serves web content to clients over the
internet. It's essentially a computer that stores website files and delivers them to web
browsers upon request.
•Function: Web servers receive HTTP requests from clients (web browsers), process
those requests, and send back the corresponding web pages or resources (HTML, CSS,
JavaScript, images, etc.).
•Examples:
•Apache HTTP Server: A popular open-source web server.
•Nginx: Another widely used open-source web server known for its performance.
•Microsoft IIS: A web server developed by Microsoft for Windows environments.
1818
KEY DIFFERENCES
The DNS Server responds with the IP address of the WEB Server.
The Browser sends over an HTTP/HTTPS request to the WEB Server’s IP (provided by
the DNS server).
The Server sends over the necessary files for the website.
The 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.
2222
2323
The Internet and the WWW(World Wide Web)
INTERconnected NETwork
24
WWW(World Wide Web)
World Wide Web, which is also known as a Web, is a collection of
websites or web pages stored in web servers and connected to local
computers through the internet. These websites contain text pages,
digital images, audios, videos, etc. Users can access the content of
these sites from any part of the world over the internet using their
devices such as computers, laptops, cell phones, etc. The WWW,
along with internet, enables the retrieval and display of text and
media to your device.
25
Evolution of the Internet
26
Evolution of the Internet
27
Evolution of the Internet
28
Evolution of the Web
29
30
Internet Overview
● Internet uses the standard Internet Protocol (TCP/IP).
● Every computer in internet is identified by a unique IP address.
● IP Address is a unique set of numbers (such as 110.22.33.114)
which identifies a computer location.
● A special computer DNS (Domain Name Server) is used to give
name to the IP Address so that user can locate a computer by a
name.
● For example, a DNS server will resolve a name
https://adelekeuniversity.edu.ng/ to a particular IP address to
uniquely identify the computer on which this website is hosted.
31
32
Intranet
Intranet is defined as private network of computers within an organization
with its own server and firewall. Moreover we can define Intranet as:
● Intranet is system in which multiple PCs are networked to be
connected to each other. PCs in intranet are not available to the world
outside of the intranet.
● Usually each company or organization has their own Intranet network
and members/employees of that company can access the computers
in their intranet.
● Every computer in internet is identified by a unique IP address.
● Each computer in Intranet is also identified by a IP Address, which is
unique among the computers in that Intranet. 33
34
Reference Model
Reference Model offers a means of standardization which is
acceptable worldwide. Since people using the computer network
are located over a wide physical range and their network devices
might have heterogeneous architecture. In order to provide
communication among heterogeneous devices, we need a
standardized model i.e. a reference model, which would provide us
way how these devices can communicate regardless their
architecture.
We have two reference models such as OSI model and TCP/IP
reference model, however, the OSI model is a hypothetical one but
the TCP/IP is absolutely practical model. 35
TCP/IP
(Transmission Control Protocol/ Internet Protocol)
These are a set of standard rules that allows different types of
computers to communicate with each other. The IP protocol
ensures that each computer that is connected to the Internet is
having a specific serial number called the IP address. TCP specifies
how data is exchanged over the internet and how it should be
broken into IP packets. It also makes sure that the packets have
information about the source of the message data, the destination
of the message data, the sequence in which the message data
should be re-assembled, and checks if the message has been sent
correctly to the specific destination. The TCP is also known as a
connection-oriented protocol.
36
The TCP/IP model is divided into four different layers:
● Application layer
● Transport layer
● Internet layer
● Network Access layer
Each layer performs a specific task on the data that is being
transmitted over the network channel, and data moves from one
layer to another in a preset pattern
37
The above model represents the flow of data when it is being transmitted
from the sender side. In the case of data being received, the layers of the
38
model work in reverse order.
Application Layer
This is the topmost layer which indicates the applications and programs that
utilize the TCP/IP model for communicating with the user through applications
and various tasks performed by the layer, including data representation for the
applications executed by the user and forwards it to the transport layer.
This layer is responsible for establishing the connection between the sender
and the receiver device and also performs the task of dividing the data from
the application layer into packets, which are then used to create sequences.
The Internet layer performs the task of controlling the transmission of the data over the
network modes and enacts protocols related to the various steps related to the transmission of
data over the channel, which is in the form of packets sent by the previous layer.
This layer performs many important functions in the TCP/IP model, some of which are:
1. It is responsible for specifying the path that the data packets will use for transmission.
2. This layer is responsible for providing IP addresses to the system for the identification
matters over the network channel.
41
Network Access Layer
This layer is the combination of data-link and physical layer, where it is responsible for
maintaining the task of sending and receiving data in raw bits, i.e., in binary format over the
physical communication modes in the network channel.
● It uses the physical address of the system for mapping the path of transmission over
the network channel.
42
Most Common TCP/IP Protocols
● TCP: Transmission Control Protocol is an internet protocol suite which breaks up the
message into TCP Segments and reassembling them at the receiving side.
● IP: An Internet Protocol address that is also known as an IP address is a numerical label. It
is assigned to each device that is connected to a computer network which uses the IP for
communication. Its routing function allows internetworking and essentially establishes
the Internet. Combination of IP with a TCP allows developing a virtual connection
between a destination and a source.
● HTTP: The Hypertext Transfer Protocol is a foundation of the World Wide Web. It is used
for transferring web pages and other such resources from the HTTP server or web server
to the web client or the HTTP client. Whenever you use a web browser like Google
Chrome or Firefox, you are using a web client. It helps HTTP to transfer web pages that43
you request from the remote servers.
• HTTPS(HyperText Transfer Protocol Secure): HTTPS is an extension of the Hypertext Transfer
Protocol (HTTP). It is used for secure communication over a computer network with the
SSL/TLS protocol for encryption and authentication. So, generally, a website has an HTTP
protocol but if the website is such that it receives some sensitive information such as credit
card details, debit card details, OTP, etc then it requires an SSL certificate installed to make
the website more secure. So, before entering any sensitive information on a website, we
should check if the link is HTTPS or not. If it is not HTTPS then it may not be secure enough to
enter sensitive information.
• SMTP: SMTP stands for Simple mail transfer protocol. This protocol supports the e-mail is
known as a simple mail transfer protocol. This protocol helps you to send the data to another
email address.
• SNMP: SNMP stands for Simple Network Management Protocol. It is a framework which is
used for managing the devices on the internet by using the TCP/IP protocol.
• DNS: DNS stands for Domain Name System. An IP address that is used to identify the
connection of a host to the internet uniquely. However, users prefer to use names instead of
addresses for that DNS. 44
• TELNET: TELNET stands for Terminal Network. It establishes the connection between the local and
remote computer. It established connection in such a manner that you can simulate your local
system at the remote system.
• FTP: FTP stands for File Transfer Protocol. It is a mostly used standard protocol for transmitting the
files from one machine to another.
• SFTP(Secure File Transfer Protocol): SFTP which is also known as SSH FTP refers to File Transfer
Protocol (FTP) over Secure Shell (SSH) as it encrypts both commands and data while in transmission.
SFTP acts as an extension to SSH and encrypts files and data then sends them over a secure shell
data stream. This protocol is used to remotely connect to other systems while executing commands
from the command line.
• POP3(Post Office Protocol 3): POP3 stands for Post Office Protocol version 3. It has two Message
Access Agents (MAAs) where one is client MAA (Message Access Agent) and another is server
MAA(Message Access Agent) for accessing the messages from the mailbox. This protocol helps us to
retrieve and manage emails from the mailbox on the receiver mail server to the receiver’s computer.
This is implied between the receiver and receiver mail server. It can also be called as one way client
server protocol. The POP3 WORKS ON THE 2 PORTS I.E. PORT 110 AND PORT 995. 45
• PPP(Point to Point Protocol): It is a communication protocol that is used to create a direct
connection between two communicating devices. This protocol defines the rules using
which two devices will authenticate with each other and exchange information with each
other. For example, A user connects his PC to the server of an Internet Service Provider also
uses PPP. Similarly, for connecting two routers for direct communication it uses PPP.
• UDP: User Datagram Protocol is responsible for identifying errors, and other tasks during
the transmission of information. UDP maintains various fields for data transmission such as:
o Source Port Address: This port is responsible for designing the application that makes up
the message to be transmitted.
o Destination Port Address: This port receives the message sent from the sender side.
o Total Length: The total number of bytes of the user datagram.
o Checksum: Used for error detection of the message at the destination side.
• ARP: This protocol refers to the Address Resolution Protocol that is responsible for finding
the physical address using the IP address. 46
OSI Model
47
48
49
All People Seem To Need Data Processing
Physical Layer
Data Link Layer
Network Layer
Transport Layer
Session Layer
Presentation Layer
Application Layer
This is the only layer that directly interacts with data from the user. Software
applications like web browsers and email clients rely on the application layer to
initiate communications. But it should be made clear that client software
applications are not part of the application layer; rather the application layer is
responsible for the protocols and data manipulation that the software relies on to
present meaningful data to the user. 50
06. THE PRESENTATION LAYER
51
This layer is primarily responsible for preparing data so that it can be used by the
application layer; in other words, layer 6 makes the data presentable for applications to
consume. The presentation layer is responsible for translation, encryption, and
compression of data.
If the devices are communicating over an encrypted connection, layer 6 is responsible for
adding the encryption on the sender’s end as well as decoding the encryption on the
receiver's end so that it can present the application layer with unencrypted, readable
data.
Finally the presentation layer is also responsible for compressing data it receives from the
application layer before delivering it to layer 5. This helps improve the speed and
efficiency of communication by minimizing the amount of data that will be transferred. 52
05. THE SESSION LAYER
53
This is the layer responsible for opening and closing communication between
the two devices. The time between when the communication is opened and
closed is known as the session. The session layer ensures that the session
stays open long enough to transfer all the data being exchanged, and then
promptly closes the session in order to avoid wasting resources.
The session layer also synchronizes data transfer with checkpoints. For
example, if a 100 megabyte file is being transferred, the session layer could
set a checkpoint every 5 megabytes. In the case of a disconnect or a crash
after 52 megabytes have been transferred, the session could be resumed
from the last checkpoint, meaning only 50 more megabytes of data need to
be transferred. Without the checkpoints, the entire transfer would have to
begin again from scratch.
54
04. THE TRANSPORT LAYER
55
Layer 4 is responsible for end-to-end communication between the two devices. This
includes taking data from the session layer and breaking it up into chunks called
segments before sending it to layer 3. The transport layer on the receiving device is
responsible for reassembling the segments into data the session layer can consume.
The transport layer is also responsible for flow control and error control. Flow control
determines an optimal speed of transmission to ensure that a sender with a fast
connection does not overwhelm a receiver with a slow connection. The transport layer
performs error control on the receiving end by ensuring that the data received is
complete, and requesting a retransmission if it isn’t.
56
03. THE NETWORK LAYER
57
The network layer is responsible for facilitating data transfer between two
different networks. If the two devices communicating are on the same
network, then the network layer is unnecessary. The network layer breaks up
segments from the transport layer into smaller units, called packets, on the
sender’s device, and reassembling these packets on the receiving device. The
network layer also finds the best physical path for the data to reach its
destination; this is known as routing.
58
02. THE DATA LINK LAYER
59
The data link layer is very similar to the network layer, except the data link
layer facilitates data transfer between two devices on the same network. The
data link layer takes packets from the network layer and breaks them into
smaller pieces called frames. Like the network layer, the data link layer is also
responsible for flow control and error control in intra-network communication
(The transport layer only does flow control and error control for inter-network
communications).
60
01. THE PHYSICAL LAYER
61
This layer includes the physical equipment involved in the data transfer, such as
the cables and switches. This is also the layer where the data gets converted
into a bit stream, which is a string of 1s and 0s. The physical layer of both
devices must also agree on a signal convention so that the 1s can be
distinguished from the 0s on both devices.
62
TCP/IP OSI Model
TCP/IP model depends on standard OSI is a generic, protocol independent
protocols about which the computer standard. It is acting as an interaction
network has created. It is a connection gateway between the network and the
protocol that assigns the network of final-user.
hosts over the internet.
6464
URL (Uniform Resource Locator)
6565
URL (Uniform Resource Locator)
• Scheme
• The first part of the URL is the scheme, which indicates the protocol that
the browser must use to request the resource (a protocol is a set method
for exchanging or transferring data around a computer network). Usually
for websites the protocol is HTTPS or HTTP (its unsecured version).
6666
URL (Uniform Resource Locator)
• Authority
Next follows the authority, which is separated from the scheme by the character pattern ://. If
present the authority includes both the domain (e.g. www.example.com) and the port (80),
separated by a colon:
• The domain indicates which Web server is being requested. Usually this is a domain name, but
an IP address may also be used (but this is rare as it is much less convenient).
• The port indicates the technical "gate" used to access the resources on the web server. It is
usually omitted if the web server uses the standard ports of the HTTP protocol (80 for HTTP
and 443 for HTTPS) to grant access to its resources. Otherwise, it is mandatory.
6767
URL (Uniform Resource Locator)
• Path to resource
6868
URL (Uniform Resource Locator)
• Parameters
6969
URL (Uniform Resource Locator)
• Anchor
• What is DNS?
• The Domain Name System (DNS) is the phonebook of the Internet. Humans
access information online through domain names, like nytimes.com or
espn.com. Web browsers interact through Internet Protocol (IP) addresses. DNS
translates domain names to IP addresses so browsers can load Internet
resources.
• Each device connected to the Internet has a unique IP address which other
machines use to find the device. DNS servers eliminate the need for humans to
memorize IP addresses such as 192.168.1.1 (in IPv4), or more complex newer
alphanumeric IP addresses such as 2400:cb00:2048:1::c629:d7a2 (in IPv6).
7171
DNS (Domain Name System)
7272
DNS (Domain Name System)
• Root nameserver - The root server is the first step in translating (resolving)
human readable host names into IP addresses. It can be thought of like an index
in a library that points to different racks of books - typically it serves as a
reference to other more specific locations.
7373
DNS (Domain Name System)
7474
75
Structure of a domain name
A domain name can be divided into three main elements based on its
structure—the top, second, and third level or subdomain.
• Top-level domain
• A top-level domain (TLD) is the final part of a web address. For example,
the TLD for google.com is .com.
• Depending on the use cases and registration requirements, there are three
types of TLDs.
7676
Structure of a domain name
7777
Structure of a domain name
• Second-level domain
• A second-level domain (SLD) is located just before the extension.
In www.adelekeuniversity.edu.ng, for example, “adelekeuniversity” is the
SLD.
• This is the only customizable part of the domain and often the most
memorable. For branding purposes, businesses should use their brand
name as the SLD.
• But what if my desired domain name is already registered? In that case, you
can search for the domain’s owner and offer to purchase the existing web
address.
8080
Structure of a domain name
• Third-level domain
• A third-level domain, better known as a subdomain, refers to the part that comes
before the main domain. The www part in most URLs is technically a subdomain,
suggesting that a website is part of the World Wide Web.
• These days, www isn’t needed anymore. Most websites work just fine without it,
and a lot of them just redirect it to the main domain, like example.com, to keep
things simple. With so many people browsing on their phones and using
apps, www has become even less necessary.
• However, some websites also have additional subdomains besides www to organize
content. For example, Google uses developers.google.com to provide information
specifically for developers.
8181
Structure of a domain name
• Third-level domain
• A subdomain is also useful for localization. Wikipedia has subdomains for different
languages—en.wikipedia.org for the English version and de.wikipedia.org for German-
speaking users, among other versions.
• Here are other common subdomain examples for a business website:
• blog.yourwebsite.com – for your blog section, which may cover company updates and
customer stories.
• news.yourwebsite.com – for the company’s latest news.
• resources.yourwebsite.com – for case studies, white papers, or eBooks.
• support.yourwebsite.com – for customer support, documentation, FAQs, and contact
information.
8282
example.co.uk
TLD
83
example.co.uk
2LD 84
example.co.uk
3LD 85
HTML
HYPERTEXT MARKUP LANGUAGE
8686
HTML
• HTML stands for Hyper Text Markup Language. It is a formatting language
used to define the appearance and contents of a web page. It allows us to
organize text, graphics, audio, and video on a web page.
• HTML is composed of elements. These elements structure the webpage
and define its content
• The word markup refers to the symbols that are used to define structure
of the text. The markup symbols tells the browser how to display the text
and are often called tags.
87
HTML Versions
The following table shows the various versions of HTML:
Version Year
XHTML 2000
HTML5 2012
88
89
All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
The Body
One of the key HTML elements we use to build a webpage is the body element. Only content
inside the opening and closing body tags can be displayed on the screen. Here’s what
opening and closing body tags look like:
<body> </body>
Once the file has a body, many different types of content – including text, images, and
buttons – can be added to the body.
<body>
<p>First Paragraph</p>
90
</body>
HTML Structure
HTML is organized as a collection of family tree relationships. When an element is
contained inside another element, it is considered the child of that element. The child
element is said to be nested inside of the parent element.
In the example above, the <p> element is nested inside the <body> element. The <p>
element is considered a child of the <body> element, and the <body> element is
considered the parent. Since there can be multiple levels of nesting, this analogy can be
extended to grandchildren, great-grandchildren, and beyond. The relationship between
elements and their ancestor and descendent elements is known as hierarchy. 91
In this example, the <body> element is the parent of the <div> element. Both the <h1> and
<p> elements are children of the <div> element. Because the <h1> and <p> elements are at
the same level, they are considered siblings and are both grandchildren of the <body>
element.
Understanding HTML hierarchy is important because child elements can inherit behavior
and styling from their parent element. You’ll understand web page hierarchy when you start
digging into CSS.
92
Headings
Headings in HTML are similar to headings in other types of media. For example, in
newspapers, large headings are typically used to capture a reader’s attention. Other times,
headings are used to describe content, like the title of a movie or an educational article.
HTML follows a similar pattern. In HTML, there are six different headings, or heading
elements. Headings can be used for a variety of purposes, like titling sections, articles, or
other forms of content.
The following is the list of heading elements available in HTML. They are ordered from
largest to smallest in size.
1. <h1> — used for main headings. All other smaller headings are used for subheadings.
2. <h2>
3. <h3>
4. <h4>
5. <h5>
6. <h6> 93
<!DOCTYPE html> •The <!DOCTYPE html> declaration defines
<html> that this document is an HTML5 document
•The <html> element is the root element of
<head>
an HTML page
<title>Page Title</title> •The <head> element contains meta
</head> information about the HTML page
<body> •The <title> element specifies a title for
the HTML page (which is shown in the
browser's title bar or in the page's tab)
<h1>My First Heading</h1> •The <body> element defines the
<p>My first paragraph.</p> document's body, and is a container for all
the visible contents, such as headings,
paragraphs, images, hyperlinks, tables,
</body> lists, etc.
</html> •The <h1> element defines a large heading
•The <p> element defines a paragraph
9494
Visualization of an HTML page structure
9595
Divs
One of the most popular elements in HTML is the <div> element. <div> is short for “division”
or a container that divides the page into sections. These sections are very useful for grouping
elements in your HTML together.
<body>
<div>
<h1>Why use divs?</h1>
<p>Great for grouping elements!</p>
</div>
</body>
<div>’s don’t inherently have a visual representation, but they are very useful when we
want to apply custom styles to our HTML elements. <div>s allow us to group HTML elements
to apply the same styles for all HTML elements inside. We can also style the <div> element as
a whole. 96
Element Meaning Purpose
<strike>/ <s> Striked Out Text To place a horizontal line across the text
• 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:
• The <hr> tag is an empty tag, which means that it has no end tag.
Example
• Use <br> if you want a line break (a new line) without starting a new paragraph:
Example
<p>This is<br>a paragraph<br>with line breaks.</p>
9999
The HTML <pre> Element
Example
<pre>
My Bonnie lies over the ocean.
100
100
HTML Styles
101
101
The HTML Style Attribute
• Setting the style of an HTML element, can be done with the style
attribute.
<tagname style="property:value;">
• The property is a CSS property. The value is a CSS
value.
102
102
Background Color
• The CSS background-color property defines the background color for an HTML element.
• Example
• Set the background color for a page to powderblue:
103
103
104
104
Text Color
• The CSS color property defines the text color for an HTML element:
Fonts
• The CSS font-family property defines the font to be used for an HTML element:
105
105
Text Size
• The CSS font-size property defines the text size for an HTML element:
• Text Alignment
• The CSS text-align property defines the horizontal text alignment for an HTML element:
106
106
HTML Quotation and Citation Elements
• We will go through the <blockquote>,<q>, <abbr>, <address>, <cite>, and <bdo> HTML elements.
• HTML <blockquote> for Quotations
• The HTML <blockquote> element defines a section that is quoted from another source.
• Browsers usually indent <blockquote> elements.
107
107
HTML <q> for Short Quotations
• The HTML <q> tag defines a short quotation.
• Browsers normally insert quotation marks around the quotation.
<p>WWF's goal is to: <q>Build a future where people live in harmony with nature.</q></p>
• The HTML <abbr> tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.", "Dr.", "ASAP",
"ATM".
• Marking abbreviations can give useful information to browsers, translation systems and search-engines.
• Tip: Use the global title attribute to show the description for the abbreviation/acronym when you mouse over
the element.
<address>
Written by John Doe.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
109
109
HTML <cite> for Work Title
• The HTML <cite> tag defines the title of a creative work (e.g. a book, a poem, a song, a movie,
a painting, a sculpture, etc.).
• Note: A person's name is not the title of a work.
• The text in the <cite> element usually renders in italic.
110
110
Attributes
If we want to expand an element’s tag, we can do so using an attribute. Attributes are content
added to the opening tag of an element and can be used in several different ways, from
providing information to changing styling. Attributes are made up of the following two parts:
● The name of the attribute
● The value of the attribute
One commonly used attribute is the id. We can use the id attribute to specify different content
(such as <div>) and is really helpful when you use an element more than once. ids have several
different purposes in HTML, but for now, we’ll focus on how they can help us identify content
on our page.
When we add an id to a <div>, we place it in the opening tag:
111
<div id="intro">
<h1>Introduction</h1>
The href Attribute </div>
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to:
112
The width and height Attributes
The <img> tag should also contain the width and height attributes, which specify the width
and height of the image (in pixels):
113
HTML Tables
ROWS
<col> Specifies column properties for each column within a <colgroup> element
117
The two attributes colspan and rowspan are used when you want to create fancy tables.
Colspan is short for "column span". colspan is used in the <td> tag to specify how many
columns the cell should span:
Cell 1
119
ROWSPAN
Cell 2
Cell 1 Cell 3
Cell 4
120
HTML FORMS
An HTML form is used to collect user input. The user input is most often sent to a server
for processing
The <form> Element
The HTML <form> element is used to create an HTML form for user input:
The <form> element is a container for different types of input elements, such as: text
fields, checkboxes, radio buttons, submit buttons, etc..
The <input> Element
An <input> element can be displayed in many ways, depending on the type attribute.
121
Type Description
enctype Specifies how the form-data should be encoded when submitting it to the server (only for
method="post")
novalidate Specifies that the form should not be validated when submitted
rel Specifies the relationship between a linked resource and the current document
target Specifies where to display the response that is received after submitting the form
123
HTML FORM ELEMENTS
<form> Defines an HTML form for user input
• The most important attribute of the <a> element is the href attribute, which indicates the link's
destination.
• The link text is the part that will be visible to the reader.
• Clicking on the link text, will send the reader to the specified URL address.
• Example
• This example shows how to create a link to W3Schools.com:
126
126
HTML Links - The target Attribute
By default, the linked page will be displayed in the current browser window. To
change this, you must specify another target for the link. The target attribute
specifies where to open the linked document. The target attribute can have one of
the following values:
● _self - Default. Opens the document in the same window/tab as it was clicked
● _blank - Opens the document in a new window or tab
● _parent - Opens the document in the parent frame
● _top - Opens the document in the full body of the window
• The previous example is an absolute URL (a full web address) in the href attribute.
• A local link (a link to a page within the same website) is specified with a relative URL (without
the "https://www" part):
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/">W3C</a></p>
<p><a href="https://www.google.com/">Google</a></p>
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>
128
128
HTML Links - Use an Image as a Link
• To use an image as a link, just put the <img> tag inside the <a> tag:
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
129
129
Button as a Link
To use an HTML button as a link, you have to add some JavaScript code.
JavaScript allows you to specify what happens at certain events, such as a click of a button:
Link Titles
The title attribute specifies extra information about an element. The information is most often
shown as a tooltip text when the mouse moves over the element.
130
130
HTML Images Syntax
• 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.
• The <img> tag has two required attributes:
• src - Specifies the path to the image
• alt - Specifies an alternate text for the image
Syntax
<img src="url" alt="alternatetext">
131
131
The src Attribute
• The required src attribute specifies the path (URL) to the image.
• 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.
132
132
• 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).
• If a browser cannot find an image, it will display the value of the alt attribute
133
133
Image Size - Width and Height
• You can use the style attribute to specify the width and height of an image.
• NOTE: The width and height attributes always define the width and height of the image in
pixels.
134
134
Common Image Formats
JPEG Joint Photographic Expert Group image .jpg, .jpeg, .jfif, .pjpeg, .pjp
PNG Portable Network Graphics .png
135
135
HTML Background Images
• You can also specify the background image in the <style> element, in the <head> section:
<style>
p {
background-image: url('img_girl.jpg');
}
</style>
136
136
Background Image on a Page
• If you want the entire page to have a background image, you must specify the background
image on the <body> element:
<style>
body {
background-image: url('img_girl.jpg');
}
</style>
137
137
Favicon
A favicon is a small image displayed next to the page title in the browser tab.
138
• To add a favicon to your website, either save your favicon image to the root directory of your
webserver, or create a folder in the root directory called images, and save your favicon image in
this folder. A common name for a favicon image is "favicon.ico".
• Next, add a <link> element to your "index.html" file, after the <title> element, like this:
139
139
ID vs CLASS
ID’s are unique
● The id attribute specifies a unique id for an HTML element. The
value of the id attribute must be unique within the HTML
document.
● The id attribute is used to point to a specific style declaration in a
style sheet. It is also used by JavaScript to access and manipulate
the element with the specific id.
● The syntax for id is: write a hash character (#), followed by an id
name. Then, define the CSS properties within curly braces {}.
140
<!DOCTYPE html>
<html>
<head>
<style>
#myHeader {
background-color: lightblue;
color: black;
padding: 40px;
text-align: center;
}
</style>
</head>
<body>
</body>
</html>
141
CLASS
● The HTML class attribute is used to specify a class for an HTML element.
● Multiple HTML elements can share the same class.
● The class attribute is often used to point to a class name in a style sheet.
It can also be used by a JavaScript to access and manipulate elements
with the specific class name.
142
<!DOCTYPE html>
<html>
<head>
<style>
.city {background-color: tomato;
color: white;
border: 2px solid black;
margin: 20px;
padding: 20px;}
</style>
</head>
<body>
<div class="city">
<h2>London</h2>
<p>London is the capital of England.</p>
</div>
<div class="city">
<h2>Paris</h2>
<p>Paris is the capital of France.</p>
</div>
</body>
</html>
143
BLOCK AND INLINE ELEMENTS
144
● An inline element does not start on a new line.
● An inline element only takes up as much width as necessary.
● Here are the inline elements in HTML:
145
DIV & SPAN ELEMENT
The <div> and <span> elements allow you to group together several elements to
create sections or subsections of a page.
This is the very important block level tag which plays a big role in grouping various
other HTML tags and applying CSS on group of elements. Even now <div> tag can
be used to create a web page layout where we define different parts (Left, Right,
Top etc.) of the page using <div> tag. This tag does not provide any visual change
on the block but this has more meaning when it is used with CSS.
146
● The HTML <span> is an inline element and it can be used to
group inline-elements in an HTML document. This tag also does
not provide any visual change on the block but has more
meaning when it is used with CSS.
● The difference between the <span> tag and the <div> tag is that
the <span> tag is used with inline elements whereas the <div>
tag is used with block-level elements.
147
HTML LAYOUT ELEMENTS
The following tags have been introduced for better structure −
section − This tag represents a generic document or application section. It can be used together with
h1-h6 to indicate the document structure.
article − This tag represents an independent piece of content of a document, such as a blog entry or
newspaper article.
aside − This tag represents a piece of content that is only slightly related to the rest of the page.
footer − This tag represents a footer for a section and can contain information about the
author, copyright information, et cetera.
nav − This tag represents a section of the document intended for navigation.
figure − This tag can be used to associate a caption together with some embedded
content, such as a graphic or video.
149
150
WHAT IS CSS?
151
What is CSS?
152
The Style Rule
CSS allows the author to specify formatting & presentation of HTML
elements using CSS Style Rules.
h1 {
font-‐size: 24px;
font-‐family: Helvetica;
color: blue;
}
153
The Syntax
Selects all h1 elements
h1 {
font-‐size: 24px;
CSS
font-‐family: Helvetica;
styles
} color: blue;
154
Selectors, Properties & Values
Selectors
font-‐size: 24px;
Selector color: blue;
font-‐family: Helvetica;
}
155
Selectors, Properties & Values
Values
156
157
158
Selectors, Properties & Values
Values
h1 {font-‐size:24px;
font-‐family:Helvetica; Values
color:blue;
}
159
CSS selectors are used to "find" (or select) the HTML elements you want to
style.
160
160
The CSS element Selector
• The element selector selects HTML elements based on the element name.
161
161
The CSS id Selector
• The id selector uses the id attribute of an HTML element to select a specific
element.
• The id of an element is unique within a page, so the id selector is used to select one
unique element!
• To select an element with a specific id, write a hash (#) character, followed by the
id of the element.
162
162
The CSS class Selector
• The class selector selects HTML elements with a specific class attribute.
• To select elements with a specific class, write a period (.) character, followed by the
class name.
163
163
The CSS class Selector
• You can also specify that only specific HTML elements should be affected by a class.
164
164
The CSS Universal Selector
The universal selector (*) selects all HTML elements on the page.
165
165
The CSS Grouping Selector
• The grouping selector selects all the HTML elements with the same style definitions.
• Look at the following CSS code (the h1, h2, and p elements have the same style
definitions):
166
166
The CSS Grouping Selector
• It will be better to group the selectors, to minimize the code.
• To group selectors, separate each selector with a comma.
167
167
How To Add CSS
When a browser reads a style sheet, it will format the HTML document
according to the information in the style sheet.
• External CSS
• Internal CSS
• Inline CSS
168
168
External CSS
• With an external style sheet, you can change the look of an entire website by
changing just one file!
• Each HTML page must include a reference to the external style sheet file inside the
<link> element, inside the head section.
• External styles are defined within the <link> element, inside the <head> section of
an HTML page:
169
169
External CSS
• An external style sheet can be written in any text editor, and must be saved with a
.css extension.
• The external .css file should not contain any HTML tags.
• Here is how the "mystyle.css" file looks:
170
170
Internal CSS
• An internal style sheet may be used if one single HTML page has a unique style.
• The internal style is defined inside the <style> element, inside the head section.
171
171
Inline CSS
• An inline style may be used to apply a unique style for a single element.
• To use inline styles, add the style attribute to the relevant element. The style
attribute can contain any CSS property.
172
172
Multiple Style Sheets
• If some properties have been defined for the same selector (element) in different
style sheets, the value from the last read style sheet will be used.
173
173
Cascading Order
What style will be used when there is more than one style specified for an
HTML element?
All the styles in a page will "cascade" into a new "virtual" style sheet by the
following rules, where number one has the highest priority:
So, an inline style has the highest priority, and will override external and
internal styles and browser defaults.
174
174
CSS Colors
175
175
CSS Background Color
You can set the background color for HTML elements:
176
176
CSS Text Color
Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod
tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl
ut aliquip ex ea commodo consequat.
178
178
CSS Color Values
In CSS, colors can also be specified using RGB values, HEX values, HSL values, RGBA values,
and HSLA values:
179
179
CSS Color Values
Same as color name "Tomato", but 50% transparent:
180
180
CSS Backgrounds
The CSS background properties are used to add background effects for elements.
181
181
CSS background-color
The background-color property specifies the background color of an element.
body {
background-color: lightblue;
}
182
182
CSS background-color
Opacity / Transparency
The opacity property specifies the opacity/transparency of an element. It can take a value from
0.0 - 1.0. The lower value, the more transparent:
183
183
CSS background-color
If you do not want to apply opacity to child elements, like in our example above, use RGBA color
values. The following example sets the opacity for the background color and not the text:
div {
background: rgba(0, 128, 0, 0.3) /* Green background with 30% opacity */
}
184
184
CSS Background Image
The background-image property specifies an image to use as the background of an element.
body {
background-image: url("paper.gif");
}
185
185
CSS background-repeat
By default, the background-image property repeats an image both horizontally and vertically.
Some images should be repeated only horizontally or vertically, or they will look strange, like
this:
186
186
Inheritance of Styles
187
Inheritance of Styles
188
Inheritance of Styles
189
Measurements in CSS
Pixels, Percentages, Ems & Rems!
In CSS, you use measurements a lot. Margin, padding, font size, width,
height, etc. all use measurements to determine the size of a specific value.
For example:
h1 {
font-‐size:2.4rem;
width: 50%;
padding: 2em;
margin: 10px;
}
190
Measurements in CSS
Pixels, Percentages, Ems & Rems!
Unit Description
Px pixels
% percent
Relative to the font size of the parent element.
em If the parent element has a font size of 14px,
then 1em = 14px
Relative to the font size of the root element
rem (html element). If the html element is 18px,
then 1rem = 18px
191
The CSS Box Model
192
The CSS Box Model
margin
padding
content area
width
border
193
Margin
Margins live outside the box. In the example, the margin has a dashed
line around it just to show the area it resides in. In the browser, margins
are invisible.
194
Margin
For
example:
h4
h4
195
Inline Elements & Margin
196
Padding
Padding resides within the box. So, you can see that the background colour in the example is the same
in the content area and the padding area.
margin
padding
Content area
width
border
197
Using Margin & Padding
To add margin & padding in CSS, all we have to do is define the size of the
margin on all four sides of the box. Here is an example:
margin-‐top: 10px;
margin-‐right: 10px;
margin-‐bottom: 10px;
margin-‐left: 10px;
198
Using Margin & Padding
Note that all four values consist of a measurement (10) and a unit (px) with
no spaces between them. In the previous example, we declared all sides of the
box to have the same values. We can write the previous example in a much
simpler way:
margin: 10px;
199
Using Margin & Padding
If any of the values are equal to 0px, we can skip writing the unit, like so:
margin: 0;
200
Using Margin & Padding
Another way of writing our margins & padding more
efficiently is like so:
201
Using Margin & Padding
Remember the order of the
values:
margin: 0 10px 20px 30px;
202
Using Margin & Padding
In some cases, you can use two
values:
margin: 0 10px;
203
Using Margin & Padding
And three values:
204
Using Margin & Padding
All of the previous techniques apply to defining padding and borders as well.
205
Borders
These guys are a little different, though. Borders don’t only have
a border-width, they also have a border-style property, and a
border-color property. Only the border-style property is
required. Here’s how you declare them:
border-‐style:solid;
border-‐width: 4px;
border-‐color:#333;
206
Borders
What if all sides have the same style, width and colour? There’s a
shorthand for that!
207
Borders
208
209
CSS Specificity
210
The Specificity Rule
211
For Example
In this example, the latter style is applied to the h1 because it comes later in the document.
212
Another Example
Even though the single em style came later in the document, it’s
font-weight will be bold, simply because the p em selector is
more specific than em alone.
213
Specificity Calculator
Classes, Elements
Inline Attributes,
, Pseudo
Styles IDs Pseudo
Classes Elements
214
For Example
h1 = Specificity of 1
215
For Example
.bass = Specificity of 10
216
For Example
217
Another Example
218
Fun Resource!
219