Before diving into the sea of web development, we must first understand how the web works.
Clients are the typical web user's internet-connected devices (for example, your computer connected to your Wi-Fi or your phone connected to your mobile network) and web-accessing software available on those devices (usually a web browser like Firefox or Chrome).
Servers are computers that store webpages, sites, or apps. When a client device wants to access a webpage, a copy of the webpage is downloaded from the server onto the client machine to be displayed in the user's web browser.
When you type a web address into your browser (for our analogy, that's like walking to the shop):
When a browser sends a request for an HTML file, it first parses the HTML.
If the HTML file contains <link>
elements that reference external CSS stylesheets, the browser sends additional requests to the server for each stylesheet in the order they appear in the HTML file.
If the HTML file contains <script>
elements that reference external JavaScript files, the browser sends additional requests to the server for each script in the order they appear in the HTML file, except for scripts with the async
ordefer
attributes set.
After the external CSS and JavaScript files are loaded, the browser constructs a Document Object Model (DOM) tree from the parsed HTML and an in-memory CSS Object Model (CSSOM) from the parsed CSS files.
The browser then applies the styles from the CSSOM to the corresponding elements in the DOM tree, and executes any JavaScript code found in the HTML or external JavaScript files.
Finally, the browser paints the visual representation of the page on the screen, allowing the user to interact with it.
The browser parses the HTML file first, which leads to the browser recognising any <link>-element references to external CSS stylesheets and any <script>-element references to scripts.
As the browser parses the HTML, it sends requests back to the server for any CSS files it has found from <link> elements and any JavaScript files it has found from <script> elements, and those then parse the CSS and JavaScript.
The browser generates an in-memory DOM tree from the parsed HTML, generates an in-memory CSSOM structure from the parsed CSS, and compiles and executes the parsed JavaScript.
As the browser builds the DOM tree and applies the styles from the CSSOM tree, and executes the JavaScript, a visual representation of the page is painted on the screen, and the user sees the page content and can begin to interact with it.
Well, it was a long typing span but still I think we have left quite some tags. Don’t worry you can still get other tags on W3Schools. But the docs many developers use are MDN Docs . I would strongly suggest reading these docs and making your own HTML practice page before continuing further.
Now that we have created the basic structure of our webpage, here comes the time to style it with colors and fonts. We use CSS to style our HTML page and make it look more beautiful. And guess where we can get all the content? At the same page we got out HTML content.
<link rel="stylesheet" href="./Club.css">
But before we begin, we must link our CSS file to our HTML file using the link tag. The rel attribute tells the HTML the type of document we want to link to our HTML file. For a CSS file it’s stylesheet. The href attribute gives the browser the destination where we have our CSS file on our system.
Now that we have the file linked, we can start our styling? But wait how do I tell the browser to apply style to a particular element. Here where the selectors come in. Here we shall only be covering the basic selectors.
p {color: white;}
.header {color: black;}
#abc {color: grey;}
HTML
<!-- This is a comment -->
<DOCTYPE html>
<html lang="en"
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document <title>
<link rel="stylesheet" href="./Club.css">
</head>
<body>
<p >Hello<p>
<p className="fresher">Freshers<p>
<p id="welcome">Welcome to the zine Recruitmeent<p>
</body>
</html>
<>
p {color: red}
.fresher {color: blue;}
#welcome {color: bisque;}
Now I can say we have figured out everything we need to do before. So let's jump in our stylings.
For starters-
Box Model
One of the most widely used styling is of box model. Basically, CSS treats every div as a box which has some properties which are
For further info about box model, you can use the above mentioned references. Also see for properties like box-shadow, etc.
CSS Layout
Well now we have boxes but how do we arrange those boxes; for this we use CSS Layout which mainly stands on these two:
Flexbox
Flexbox is an arrangement of boxes in one direction like a row or a column. To enable flexbox, we set:
display: flex;
Grid
Grid is more of a 2-D arrangement of elements. To set up a grid, we can use:
display: grid; grid-template-columns: 200px 300px; grid-template-rows: 100px 50px;
This gives an arrangement as:
JavaScript
We have the bricks and color now let's add functionality. JavaScript is the programming language widely used for both client-side and server-side of a web app. Let's breakdown the language first.
Variables
JS is dynamically typed so we don't have any use for declaring the type of variables. We popularly use let and const for variable declaration.
const x = 10; let y = 12;
There is also another method to declare a variable using var keyword but its use is discontinued with time due to security reasons. Along with primary data types we also have array and objects in JS.
We have both if else and switch statements in JS.
switch (key) {
case value: break; default: break;
}
if (condition) {
}else{
}
We have aall three loops in Js
do {
} while (condition); while (condition) {
}
for (let index = 0; index < length; index++) {
}
function name(params) {
}
Now that we are familiar with the basic concepts of JS. We are moving to DOM (Document Object Model) and Event Listeners.
The above shows the DOM tree generated during rendering a webpage. In the DOM model we can access every part of the document by an object in JS by using query selector.
These selectors are –
It’s by using these selectors that we can interact with the HTML elements, add an event listener and much more. For sake of simplicity we are just going to show one example of the event listeners.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button id="click">Click me !!!</button>
</body>
</html>
function onClick()
alert("Hello Freshers");
let button = document.getElementById("click");
button.addEventListener("click", onClick);
When Clicked
Problem Statement – Build a Portfolio using HTML, CSS and JS. It must contain a Homepage (Landing Page), About, Works, Services, Contact and must be at least a two-page Portfolio with both pages linked to each other. Also include link to your GitHub profile in the portfolio and deploy it. Send us the link of the deployed site to the same on zine.nitj@gmail.com
Robotics &
Research
Group
GROUP
Home
Team
Alumni
PROJECTS
Achievements
Projects
Contribute
ACTIVITIES
Workshops
Blogs
Gallery
COPYRIGHT 2023, ZINE
zine.nitj@gmail.com