Javascript Articles

Page 291 of 534

How to preselect Dropdown Using JavaScript Programmatically?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we will learn how to preselect dropdown options using JavaScript programmatically. This is useful when you want to set default selections based on user preferences, data from APIs, or other dynamic conditions. A dropdown list is a toggle menu that allows users to select one option from multiple choices. In HTML, dropdown lists are created using the element combined with elements. JavaScript provides several methods to programmatically control these selections. There are two primary methods to preselect dropdown options: using the selectedIndex property and using the value property. Let's explore both approaches. ...

Read More

How to draw a star in HTML5 SVG?

Govinda Sai
Govinda Sai
Updated on 15-Mar-2026 9K+ Views

SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML. Most web browsers can display SVG just like they can display PNG, GIF, and JPG. To draw a star in HTML5 SVG, we use the element. The key is to set the correct x and y coordinates for each point of the star, alternating between outer points (tips) and inner points (valleys). 5-Point Star using SVG Polygon ...

Read More

Create a small-caps effect for CSS

Abhinaya
Abhinaya
Updated on 15-Mar-2026 567 Views

To create a small-caps effect in CSS, use the font-variant property with the value small-caps. This transforms lowercase letters into smaller uppercase letters while keeping original uppercase letters at their normal size. Syntax font-variant: small-caps; Example Here's how to apply the small-caps effect to text: .small-caps { font-variant: small-caps; font-size: 18px; ...

Read More

How to use JavaScript to redirect an HTML page?

Rishi Raj
Rishi Raj
Updated on 15-Mar-2026 2K+ Views

You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection. JavaScript provides several methods to redirect users from one page to another. This is commonly used for routing users after form submissions, authentication, or when content has moved to a new location. Methods for Page Redirection There are three main ways to redirect pages using JavaScript: Using window.location.href The most common method assigns a new URL to window.location.href: ...

Read More

Set the font style with CSS

radhakrishna
radhakrishna
Updated on 15-Mar-2026 218 Views

To set the font style, use the font-style property. This CSS property allows you to make text appear italic, normal, or oblique. Syntax font-style: normal | italic | oblique; Values normal - Default font style (upright text) italic - Slanted version of the font (if available) oblique - Artificially slanted text Example: Italic Font Style You can try to run the following code to set the font-style to italic with CSS: Font Style Example ...

Read More

How to use Meta Tag to redirect an HTML page?

Paul Richard
Paul Richard
Updated on 15-Mar-2026 13K+ Views

Page redirection is a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection. To use a META Tag to redirect your site is quite easy. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. ...

Read More

How to fix problems related to the JavaScript Void 0 Error?

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 2K+ Views

The JavaScript "void(0)" error typically occurs when JavaScript is disabled in the browser or when there are issues with JavaScript execution. This error commonly appears as "javascript:void(0)" in links or when scripts fail to run properly. What is JavaScript void(0)? The void operator in JavaScript evaluates an expression and returns undefined. When used as void(0) or void 0, it simply returns undefined without executing any meaningful operation. console.log(void(0)); // undefined console.log(void 0); // undefined console.log(void(1 + 2)); ...

Read More

Usage of font-style property in CSS

Giri Raju
Giri Raju
Updated on 15-Mar-2026 106 Views

The font-style property in CSS is used to specify whether text should be displayed in normal, italic, or oblique style. This property allows you to add emphasis to text by changing its visual appearance. Syntax font-style: normal | italic | oblique; Values normal - Default value. Text is displayed normally italic - Text is displayed in italic style (slanted) oblique - Text is displayed in oblique style (artificially slanted) Example: Basic Font Style Usage ...

Read More

How can I force clients to refresh JavaScript files?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 12K+ Views

When you update JavaScript files on your server, browsers may still load the old cached version instead of your new code. This tutorial shows you how to force browsers to reload updated JavaScript files automatically. The problem occurs because browsers cache JavaScript files locally for faster loading. When you deploy new code, browsers continue serving the old cached files instead of fetching updated ones from the server. This causes users to see outdated functionality even after you've deployed new features or fixes. Understanding Browser Caching When users visit your application, browsers store CSS and JavaScript files in ...

Read More

Set the font variant with CSS

Ankitha Reddy
Ankitha Reddy
Updated on 15-Mar-2026 131 Views

The CSS font-variant property controls how text is displayed, allowing you to transform lowercase letters into small capital letters or display text normally. Syntax font-variant: normal | small-caps | inherit; Parameters Value Description normal Default value. Text displays normally small-caps Converts lowercase letters to small capital letters inherit Inherits the font-variant from parent element Example: Using small-caps .small-caps { ...

Read More
Showing 2901–2910 of 5,340 articles
« Prev 1 289 290 291 292 293 534 Next »
Advertisements