The perimeter of a rectangle is the total distance around the outside edge of the shape. Whether you are measuring a garden fence, a picture frame, or a building foundation, knowing the perimeter is essential for determining the amount of material needed to enclose a space.
Perimeter (P) = 2 × (Length + Width)
The Step-by-Step Calculation Process
Calculating the perimeter is a straightforward three-step process:
Measure the Length: Determine the longest side of the rectangle.
Measure the Width: Determine the shorter side of the rectangle.
Apply the Formula: Add the length and the width together, then multiply the sum by 2.
Alternatively, you can simply add all four sides together: Length + Length + Width + Width = Perimeter.
Practical Examples
Object
Length
Width
Perimeter Calculation
Smartphone Screen
15 cm
7 cm
2 × (15 + 7) = 44 cm
Standard Door
80 inches
36 inches
2 × (80 + 36) = 232 inches
Small Garden Plot
10 meters
5 meters
2 × (10 + 5) = 30 meters
Perimeter vs. Area
It is important not to confuse perimeter with area. While perimeter measures the distance around the shape (linear units), area measures the space inside the shape (square units). For a rectangle with a length of 5m and a width of 3m:
Perimeter: 2 × (5 + 3) = 16 meters
Area: 5 × 3 = 15 square meters
function calculateRectanglePerimeter() {
var length = document.getElementById("rectLength").value;
var width = document.getElementById("rectWidth").value;
var unit = document.getElementById("unitSelect").value;
var resultDiv = document.getElementById("resultContainer");
var resultValue = document.getElementById("perimeterResult");
// Validate inputs
if (length === "" || width === "" || parseFloat(length) <= 0 || parseFloat(width) <= 0) {
alert("Please enter valid positive numbers for both length and width.");
resultDiv.style.display = "none";
return;
}
var l = parseFloat(length);
var w = parseFloat(width);
// Logic: P = 2 * (L + W)
var perimeter = 2 * (l + w);
// Format result to handle floating point precision
var formattedResult = Number.isInteger(perimeter) ? perimeter : perimeter.toFixed(2);
// Display results
resultValue.innerHTML = formattedResult + " " + unit;
resultDiv.style.display = "block";
}