Web Developer Notes - Page 7

code

How to Remove WWW From a Website Address

Last updated: 26.10.2025
Views: 308
A redirect is to redirect site visitors from one URL to another. 301 status indicates that the redirect is permanent. Removing www from the site address is necessary primarily for SEO. Since sites with www and without for search engines are different sites with the same content. For Apache server, you need to make an entry in the .htaccess file. [bash] RewriteCond %{HTTP_HOST} ^www.example.co...
JavaScript

How to Сlone (Copy) Object and Array in JavaScript

Last updated: 21.02.2026
Views: 209
Cloning objects and arrays is not as simple a topic as it may seem at first glance. Cloning objects and arrays in JavaScript can be done using various methods depending on the complexity (shallow vs. deep cloning). Cloning an Array 1. Using the Spread Operator (...): [js] const originalArray = [1, 2, 3]; const clonedArray = [...originalArray]; console.log(clonedArray); // Output: [1, 2, 3]...
css

How to Center an Element Vertically Using CSS (Vertical Alignment)

Last updated: 21.02.2026
Views: 205
There are several ways of vertical alignment. In different situations, different ways are suitable. Consider some of them. 1. Using Flexbox The easiest and most widely used method: [css] .container { display: flex; align-items: center; /* Centers vertically */ justify-content: center; /* Optional: Centers horizontally */ height: 100vh; /* Full viewport height, if needed. Or set you...
JavaScript

Countdown Timer in JavaScript

Last updated: 21.02.2026
Views: 208
Often on sites that sell something, you can find a countdown timer to a certain date. Such a script is usually needed for landing pages or online stores. In one of the previous articles, we looked at creating a simple clock in JavaScript. Now we will consider a slightly more complex but at the same time more practical example of working with the Date object. Let's write a countdown timer in JavaSc...
php

How to Upload Files to a Server Using PHP

Last updated: 21.02.2026
Views: 183
Uploading files to a website is a common task. Consider uploading files to a PHP server using the POST method. This will require a form with the "file" field type and an enctype attribute with a multipart/form-data value. We will not use AJAX in this example, but will do a regular HTML form submission. HTML [html] <form method="POST" enctype="multipart/form-data"> &l...