Essential Web Technologies: HTML Structure and JavaScript Functions

HTML: Web Page Structure

HTML (HyperText Markup Language) is the standard language used to create the structure of web pages. It is not a programming language; rather, it is a markup language that tells the web browser how to display content like text, images, and links.

It uses a system of tags (keywords enclosed in angle brackets like <html>) to wrap around content and give it meaning.

1. <h1> to <h6> (Heading Tags)

These tags are used to define headings on a page. <h1> is the most important (main title), and <h6> is the least important (sub-headers).

Purpose: To give structure and hierarchy to your content.

Example: <h1>Welcome to My Blog</h1>

2. <p> (Paragraph Tag)

The <p> tag is used to define a block of text as a paragraph. Browsers automatically add some space (margin) before and after each <p> element.

Purpose: To organize regular body text.

Example: <p>This is a sentence inside a paragraph.</p>

3. <a> (Anchor Tag)

The anchor tag is used to create hyperlinks that connect one page to another or to an external website. It requires an href attribute to specify the destination.

Purpose: Navigation.

Example: <a href="https://www.google.com">Click here to visit Google</a>

4. <img> (Image Tag)

This tag is used to embed images into a webpage. Unlike most tags, it is self-closing, meaning it doesn’t need an </img> end tag. It requires a src (source) and an alt (alternative text) attribute.

Purpose: To display visual content.

Example: <img src="logo.png" alt="Company Logo">

5. <ul> and <li> (Unordered List Tags)

The <ul> tag defines an unordered (bulleted) list, and the <li> tag defines each individual item within that list.

Purpose: To group related items in a list format.


JavaScript Functions: Reusable Code Blocks

A function in JavaScript is a reusable block of code designed to perform a particular task. You can think of it as a “recipe”: you define the steps once, and then you can “cook” (execute) that recipe whenever you need it without rewriting the steps.

Components of a Function

Parameters: These are the “placeholders” listed in the function definition (like name in the example above).

Arguments: These are the actual values you pass to the function when you call it (like "Rahul").

Return Statement: A function can send a value back to the place where it was called using the return keyword.

Why Are Functions Useful?

Functions are the building blocks of any JavaScript application for several reasons:

1. Code Reusability

Instead of writing the same 10 lines of code every time you need to calculate a tax or format a date, you write it once in a function and call it 100 times.

2. Organization and Readability

Functions allow you to break a large, complex program into smaller, manageable “chunks.” For example, instead of one giant script, you can have calculateTotal(), validateEmail(), and saveData().

3. Easier Maintenance

If there is an error in your logic, you only have to fix it in one place (inside the function) rather than searching through your entire codebase to find every instance where you wrote that logic.

4. Abstraction

Functions allow you to use code without knowing exactly how it works inside. For example, you can use a sendEmail() function without knowing the complex server protocols happening behind the scenes.


Web Browser Operations

A Web Browser is a software application designed to retrieve, present, and traverse information on the World Wide Web. While the Internet is the “road,” the Browser is the “vehicle” you use to travel on it.

Common examples include Google Chrome, Apple Safari, Mozilla Firefox, Microsoft Edge, and Opera.

The Role of a Browser in the Internet

The browser acts as a bridge between a human and the complex technical infrastructure of the internet. Here is exactly what it does:

1. The “Translator” (Rendering Engine)

Websites are written in code like HTML, CSS, and JavaScript. Humans cannot easily read these raw files. The browser’s primary job is to take this code and render it into a visual page with text, images, and buttons that you can actually use.

2. Requesting and Fetching Data

When you type a URL (like www.google.com) or click a link, the browser starts a conversation with a Server.

It sends a request using a protocol called HTTP/HTTPS.

It receives the files (text, images, scripts) from the server and assembles them on your screen.

3. Executing JavaScript

Modern browsers have a “JavaScript Engine” (like Chrome’s V8 engine). This allows the browser to run complex programs—like Google Maps or a web-based game—directly in your browser without needing to install separate software.

How a Browser Works (Step-by-Step)

Input: You enter a web address.

DNS Lookup: The browser contacts a Domain Name System to find the numerical IP address of that website.

The Request: The browser sends a “GET” request to that IP address.

The Response: The server sends back the website’s files.

The Build: The browser builds the DOM (Document Object Model) to understand the structure and the CSSOM to understand the style.

Display: The browser paints the pixels on your screen.


Java Memory Management: Garbage Collection

In Java, Garbage Collection (GC) is an automatic process of memory management. Its main objective is to identify and delete objects that are no longer reachable by the application, thereby freeing up space in the Heap Memory for new objects.

In older languages like C or C++, programmers had to manually allocate and free memory, which often led to “Memory Leaks.” Java handles this automatically, making it more robust.

Java’s GC follows a “Mark and Sweep” strategy:

  1. Marking: The GC identifies which pieces of memory are in use and which are not. It starts from “GC Roots” (like active threads or local variables) and follows every reference to find all reachable objects.

  2. Sweeping: The GC removes the unreachable objects.

  3. Compacting (Optional): After deleting unreachable objects, the GC may move the remaining objects together to create a large contiguous block of free memory, preventing fragmentation.