In the previous lecture, we learned:
In this lecture, we will learn:
Float is used to align elements horizontally on a webpage.
Normally, block elements appear one below another.
Header
Content
Footer
Using float, elements can appear side by side.
Sidebar Content Area
Float is commonly used to:
float:left;
or
float:right;
Moves element toward the left side.
float:left;
Moves element toward the right side.
float:right;
Removes float behavior.
float:none;
Inherits float value from parent element.
float:inherit;
+-----------------------+
| Sidebar | Content |
+-----------------------+
The sidebar may float left while the content area appears beside it.
Sometimes floated elements create layout problems.
To stop floating behavior, CSS provides the clear property.
Stops elements from appearing beside left floated elements.
clear:left;
Stops elements from appearing beside right floated elements.
clear:right;
Stops elements from appearing beside either left or right floated elements.
clear:both;
Without clearing floats:
Header
Sidebar Content
Footer (May move upward)
With clear:
Header
Sidebar Content
Footer
The footer stays in the correct position.
In older websites, developers often used the <br> tag to stop floating.
<br clear="all">
This forces the next content to appear below all floated elements.
Sidebar Content
<br clear="all">
Footer
Modern developers usually prefer CSS:
clear:both;
However, you should know both techniques because many old websites still use them.
Your task is to design a simple webpage layout using everything learned so far.
Create a main container having:
Width: 980px
The container will hold all webpage sections.
Create a header section at the top.
Requirements:
The header should represent the website title area.
Create a sidebar section.
Requirements:
Width: 250px
The sidebar should appear on the left side.
Possible content:
Create a content section beside the sidebar.
Requirements:
Border: 2px
Padding: 10px
The content area should occupy the remaining available width.
Add sample text inside the content section.
Create a footer at the bottom.
The footer should contain three buttons:
Home
About Us
Contact Us
The footer must appear below both the sidebar and content area.
This assignment will help you practice:
Border Radius is used to create rounded corners.
Without border-radius:
+----------+
| |
+----------+
With border-radius:
/----------\
| |
\----------/
border-radius:10px;
button{
border-radius:10px;
}
border-radius:5px;
border-radius:10px;
border-radius:20px;
border-radius:50%;
Now we begin learning JavaScript.
JavaScript is one of the most popular programming languages used in web development.
JavaScript is:
JavaScript can:
A webpage is built using:
Structure
Skeleton
Design
Appearance
Behavior
Actions and Interaction
Events occur when users interact with a webpage.
Triggered when user clicks an element.
onclick
Example:
Click a button
Show a message
Triggered when mouse enters an element.
onmouseover
Example:
Mouse enters image
Image changes color
Triggered when mouse leaves an element.
onmouseout
Example:
Mouse leaves image
Image returns to original color
Triggered when a form is submitted.
onsubmit
Example:
Validate form
Check required fields
Submit data
JavaScript provides built-in objects.
The browser window is represented by:
window
The window object controls browser-related functionality.
The webpage itself is represented by:
document
JavaScript uses the document object to access HTML elements.
Used to display output on a webpage.
document.write("Hello");
Hello
Functions are reusable blocks of code.
Instead of writing the same code repeatedly, we place it inside a function.
function functionName()
{
}
function sayHello()
{
alert('Hello');
}
Whenever the function is called, the alert message appears.
Alert is one of the simplest JavaScript functions.
It displays a popup message.
alert('Hello');
+----------------+
| Hello |
| OK |
+----------------+
JavaScript code is written inside the <script> tag.
<script type="text/javascript" language="java">
</script>
<script>
</script>
The script tag tells the browser:
JavaScript code starts here.
We have now started JavaScript fundamentals.
Our learning roadmap is:
HTML
↓
CSS
↓
JavaScript
↓
PHP
↓
jQuery
In this lecture, we learned:
In the next lecture, we will continue with JavaScript fundamentals and learn how JavaScript interacts with HTML elements and user actions.