Lec 02
Lec 02
Lec 02
Development (Part 2)
Introduction
2
CSS - Enhancing Aesthetics
3
CSS can customize appearance in a variety of
ways, including:
Changing colors: CSS can be used to change body {
the color of any element on a web page, color: red;
}
including text, backgrounds, borders, and links.
For example, the following CSS code would
change the color of all of the text on a page to
red: h1, h2, h3, h4, h5, h6 {
Changing fonts: CSS can be used to change font-family: Arial;
}
the font of any text on a web page. For example,
the following CSS code would change the font of
all of the headings on a page to Arial:
Changing spacing: CSS can be used to change body {
padding: 10px;
the spacing around and between elements on a }
web page. For example, the following CSS code
would add 10 pixels of padding to all of the img {
elements on a page: }
animation: fadein 2s ease-in-out;
4
The Role of CSS
5
Anatomy of CSS
body {
font-family: Arial, sans-serif;
In this code snippet, you can see how selectors
background-color: #f2f2f2; (e.g., body, h1, p) are used to target specific
} HTML elements, and within each block,
h1 {
properties (e.g., font-family, color, font-size) are
color: #007bff; paired with corresponding values to define the
} styling for those elements. This combination of
p{
selectors and declaration blocks is the
font-size: 16px; fundamental structure of CSS rules.
line-height: 1.5;
}
6
CSS Selectors
7
CSS Properties and Values
8
Example - Applying CSS Styles
HTML Structure:
Demonstrative HTML structure comprising elements like head, title, link, /* styles.css */
body, header, h1, article, and h2. body {
Linked External CSS: font-family: Arial, sans-serif;
An external CSS file, "styles.css," is linked to the HTML document using margin: 0;
the <link> element in the <head> section. padding: 0;
CSS Styling Code: background-color: #f7f7f7;
Corresponding CSS code in "styles.css" for styling the HTML elements.
}
<!DOCTYPE html> header {
<html> text-align: center;
<head> padding: 20px;
<title>My Blog Post</title> background-color: #333;
<link rel="stylesheet" href="styles.css"> color: #fff;
</head> }
<body> h1 {
<header> font-size: 36px;
<h1>Welcome to My Blog</h1> }
</header>
<article> article {
<h2>Exploring the Wonders of CSS</h2> margin: 20px;
<p>Cascading Style Sheets (CSS) allow us to...</p> padding: 15px;
background-color: #fff;
</article> box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
</body> }
</html>
h2 {
color: #007bff;
}
9
JavaScript - Breathing Interactivity
JavaScript's Role:
JavaScript serves as the dynamic force that transforms static HTML and
CSS into interactive and lively web experiences.
Interaction and Responsiveness:
JavaScript responds to user actions, enabling modifications to content
and adding a dynamic layer to web pages.
Enhancing User Experience:
By introducing interactivity and real-time updates, JavaScript enriches the
user experience, making web applications more engaging and functional.
10
JavaScript's Role
Enhancing Interactivity:
JavaScript plays a pivotal role in enhancing interactivity on the web.
Browser-Based Operations:
Operating within the browser environment, JavaScript dynamically
manipulates elements and swiftly responds to user actions.
JavaScript's ability to facilitate real-time interactions and
manipulate web content in response to user input makes it an
essential language for creating engaging and responsive web
applications.
11
JavaScript and the DOM
12
Event Handling in JavaScript
13
Interactive Forms with JavaScript
14
Dynamic Content Updates with JavaScript
15
CSS and JavaScript Collaboration
16
Responsive Design Essentials
17
Media Queries in Responsive Design
18
Example - Responsive Design
This example demonstrates responsive design using media
/* Styles for desktop screens */
queries. The CSS code in "styles.css" adjusts the layout for header {
smaller screens (max-width: 768px), making it more readable background-color: #007bff;
and user-friendly. The navigation menu items are aligned padding: 20px;
text-align: center;
vertically, and the font size is reduced, ensuring a better user }
experience on various devices.
nav ul {
<!DOCTYPE html> display: flex;
<html> list-style: none;
<head>
padding: 0;
<title>Responsive Design Example</title>
<link rel="stylesheet" href="styles.css">
}
</head>
<body> nav li {
<header> margin-right: 20px;
<h1>My Responsive Website</h1> }
<nav>
<ul> /* Styles for smaller screens */
<li><a href="#">Home</a></li> @media screen and (max-width: 768px) {
<li><a href="#">About</a></li> body {
<li><a href="#">Services</a></li> font-size: 14px;
<li><a href="#">Contact</a></li> }
</ul>
</nav> header {
</header> padding: 10px;
<section> }
<h2>Welcome to Our Website</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nav ul {
consectetur leo vel urna varius, et iaculis velit fermentum.</p> flex-direction: column;
</section>
align-items: center;
</body>
}
</html>
}
19
Web Accessibility
20
Web Accessibility Principles
enhancing inclusivity.
Example: <img src="image.jpg" alt="A group of diverse people working together in a collaborative
environment.">
Keyboard Navigation for Accessibility:
Keyboard navigation ensures that users who rely on keyboards, rather than mice, can efficiently
access and interact with web elements.
Example: <button id="ctaButton" tabindex="0">Click Here</button>
Contrast for Readability:
Proper color contrast ensures content is legible for users with vision impairments or in various lighting
conditions.
ARIA Roles for Enhanced Interactivity:
ARIA (Accessible Rich Internet Applications) roles and attributes enhance interactivity and assistive
technology compatibility.
Example: <div role="navigation">...</div>
By adhering to these web accessibility principles, designers and developers create digital
experiences that are inclusive and accessible to all users, regardless of their abilities or
assistive technology.
21
Embracing Inclusivity
22