Found 8591 Articles for Front End Technology

How to set the vertical alignment of the content in an element with JavaScript?

Shubham Vora
Updated on 09-Nov-2022 10:55:48

1K+ Views

In this tutorial, we will learn how to set the vertical alignment of the content in an element in JavaScript. The vertical-align property of HTML DOM Style is used to set the vertical alignment of the content in an element. The vertical-align attribute specifies or returns the vertical alignment of an element's content. The vertical-align attribute controls the vertical alignment of an inline-block or table-cell box. The vertical-align attribute is used to align the box of an inline element within its line box vertically. It may, for example, be used to arrange a picture within a line of text vertically. ... Read More

How to set whether the text of an element can be selected or not with JavaScript?

Shubham Vora
Updated on 12-Oct-2022 11:23:04

263 Views

In this tutorial, we will learn to set whether the text of an element can be selected or not with JavaScript. Use the userSelect property in JavaScript to enable or disable a text selection. For Firefox, use the MozUserSelect property and set it to none, to disable the selection. The CSS user-select property can set the text on a web page as selectable or nonselectable. But, sometimes, we must restrict the selection to a triggered event or a condition. Then, we can use the JavaScript DOM that provides nearly all CSS properties. So, let us look ... Read More

How to set the capitalization of a text with JavaScript?

Ramu Prasad
Updated on 23-Jun-2020 11:35:30

227 Views

To set the capitalization, use the textTransform property in JavaScript. Set it to capitalize, if you want the first letter of every word to be a capital letter.ExampleYou can try to run the following code to return the capitalization of a text with JavaScript −           Capitalize Text                This is demo text! This is demo text!                      function display() {             document.getElementById("myID").style.textTransform = "capitalize";          }          

How to set the shadow effect of a text with JavaScript?

Sravani S
Updated on 23-Jun-2020 11:23:38

928 Views

To set the shadow effect, use the textShadow property in JavaScript.ExampleYou can try to run the following code to return the shadow effect of a text with JavaScript −           Set Text Shadow                This is Demo Text! This is Demo Text! This is This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text!                      function display() {             document.getElementById("myID").style.textShadow = "2px 2px 2px #ff0000,20px 5px 2px #F1F1F1";          }          

What is to be done when text overflows the containing element with JavaScript?

Krantik Chavan
Updated on 23-Jun-2020 11:36:08

99 Views

Use the textOverflow property to counter the text overflow issue. Add ellipses if the text overflows the containing element.ExampleYou can try to run the following code to learn what is to be done when text overflows the containing element with JavaScript −                    #myID {             border: 2px solid blue;             background-color: gray;             overflow: hidden;             text-overflow: visible;             width: 200px;       ... Read More

How to set the indentation of the first line of text with JavaScript?

Shubham Vora
Updated on 15-Nov-2022 07:56:26

2K+ Views

In this tutorial, we will learn how to set the indentation of the first line of text with JavaScript. The indentation of the first line of a text is a common way to start a new paragraph. To set the indentation, use the textIndent property. To set the indentation of the first line of text with JavaScript, we will discuss two different ways − Using the style.textIndent Property Using the style.setProperty Method Using the style.textIndent Property The style.textIndent property of an element is used to set the indentation of the first line of text. This property is placed ... Read More

How to set the style of the line in a text decoration with JavaScript?

Shubham Vora
Updated on 22-Nov-2022 07:37:42

1K+ Views

In this tutorial, we shall learn to set the style of the line in a text decoration with JavaScript. To set the style of the line in JavaScript, use the textDecorationStyle property. You can set underline, double, or overline, etc. for the line style. Let us discuss our topic in brief. Using the Style textDecorationStyle Property We can set or return the line style in a text decoration with this property. The major browsers support this property. Firefox adds support with an alternate property named MozTextDecorationStyle. Syntax Following is the syntax to set the style of the line in ... Read More

How to set the bottom position of 3D elements with JavaScript?

Shubham Vora
Updated on 12-Oct-2022 11:32:52

249 Views

In this tutorial, we will learn how to set the bottom position of 3D elements with JavaScript. In a web page, handling a 3D element can be tricky. Using JavaScript, we had to set the top, bottom, sides, etc. To set the bottom position of 3D elements, we use the perspectiveOrigin property of an element’s style object. Using style.perspectiveOrigin Property In JavaScript, the style.perspectiveOrigin property is used to set the bottom position or base position of a 3D element. Firstly, we get the element object using the document.getElementById() method and then set the style.perspectiveOrigin property. ... Read More

How to set the type of line in a text-decoration with JavaScript?

Jennifer Nicholas
Updated on 23-Jun-2020 11:26:01

169 Views

To set the type of line in text-decoration, use the textDecorationLine property. You can try to run the following code to return the type of line in a text-decoration with JavaScript −Example                    This is demo text.                   Set Text Decoration                function display() {             document.getElementById("myText").style.textDecorationColor = "red";             document.getElementById("myText").style.textDecorationLine = "overline";          }          

How to set the top padding of an element with JavaScript?

Priya Pallavi
Updated on 23-Jun-2020 11:26:36

609 Views

Use the paddingTop property in JavaScript to set the top padding. You can try to run the following code to set the top padding of an element with JavaScript −Example                    #box {             border: 2px solid #FF0000;             width: 150px;             height: 70px;          }                     This is demo text.             Top Padding                      function display() {             document.getElementById("box").style.paddingTop = "20px";          }          

Advertisements