Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Front End Scripts Articles
Page 14 of 47
Set the background color of an element with CSS
To set the background color of an element, use the background-color property in CSS. This property accepts color values in various formats including color names, hex codes, RGB, and HSL values. Syntax background-color: color-value; Example Here's how to set background colors using different methods: Background Color Example This text has a blue background color. ...
Read MoreSet the Background Image Position with CSS
To set the background image position, use the background-position property. This CSS property controls where the background image is positioned within its container element. Syntax background-position: horizontal vertical; The property accepts various values including pixels, percentages, and keywords like left, right, center, top, and bottom. Example: Positioning with Pixels This example sets the background image position 80 pixels from the left and centers it vertically: body { ...
Read MoreCreate a small-caps effect for CSS
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 MoreSet the font style with CSS
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 MoreUsage of font-style property in CSS
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 MoreIs there a Microsoft equivalent for HTML5 Server-Sent Events?
HTML5 Server-Sent Events (SSE) provide real-time communication from server to client. While not natively supported in older Internet Explorer versions, there are Microsoft-compatible alternatives to achieve similar functionality. What are Server-Sent Events? Server-Sent Events allow a web page to receive automatic updates from a server through a persistent HTTP connection. Unlike WebSockets, SSE provides unidirectional communication from server to client only. if (typeof EventSource !== "undefined") { var source = new EventSource("/events"); source.onmessage = function(event) { ...
Read MoreWhat exactly is the pushState state object in HTML?
The pushState state object is a JavaScript object that stores data associated with a specific history entry in the browser's history stack. It allows you to save information that can be retrieved when the user navigates back or forward through history. Syntax history.pushState(state, title, url); Parameters state - An object containing data to associate with the history entry title - The title for the new history entry (often ignored by browsers) url - The new URL to display in the address bar Example: Creating History Entries with State ...
Read MoreSet the font variant with CSS
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 MoreHow to reconnect to websocket after close connection with HTML?
WebSockets are designed to maintain persistent connections, but they can close due to network issues, server restarts, or connection timeouts. When a WebSocket connection closes, you need to manually recreate the socket to reconnect. How WebSocket Reconnection Works When a WebSocket connection closes, the onclose event fires. You can handle this event to automatically attempt reconnection by creating a new WebSocket instance and reattaching event listeners. Basic Reconnection Example // Socket Variable declaration var mySocket; const socketMessageListener = (event) => { console.log('Received:', event.data); }; // Connection opened const ...
Read MoreUsage of font-size property in CSS
The font-size property in CSS controls the size of text elements. It accepts various units and keywords to specify how large or small text should appear on a webpage. Syntax font-size: value; Font Size Values The font-size property accepts several types of values: Absolute keywords: xx-small, x-small, small, medium, large, x-large, xx-large Relative keywords: smaller, larger Length units: pixels (px), em, rem, points (pt) Percentage: relative to parent element's font size Example: Different Font Size Values ...
Read More