Javascript Articles - Page 560 of 671

How to set the font size of text with JavaScript?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

924 Views

To set the font size, use the fontSize property in JavaScript. You can try to run the following code to set the font size of the text with JavaScript − Example Live Demo Heading 1 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. Set Font Family and Size function display() { document.getElementById("myID").style.fontFamily = "verdana,sans-serif"; document.getElementById("myID").style.fontSize = "smaller"; }

How to set the minimum number of lines for an element that must be left at the bottom of a page when a page break occurs inside an element with JavaScript?

Srinivas Gorla
Updated on 23-Jun-2020 12:33:48

124 Views

Use the orphans property in JavaScript to set the minimum number of lines for an element that should be left at the bottom of a page when a page break occurs inside an element with JavaScript.You can return the orphans property like this −var res = object.style.orphansSet the orphans property like this −object.style.orphans = 'number|initial|inherit'The following are the property values shown above −number − Specify the minimum number of visible lines.Initial − Set property to its defaultInherit − Inherits property from the parent element

How to set the page-break behavior before an element with JavaScript?

Nancy Den
Updated on 23-Jun-2020 12:32:23

559 Views

Use the pageBreakBefore property in JavaScript to set the page-break behavior before an element. Use the always property to insert a page break before an element.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior before an element with JavaScript −           Heading 1       This is demo text.       This is demo text.       This if footer text.       Set page-break                      function display() {             document.getElementById("myFooter").style.pageBreakBefore = "always";          }          

How to set the horizontal alignment of an element with JavaScript?

Monica Mona
Updated on 23-Jun-2020 12:34:52

373 Views

To align the element horizontally, use the cssFloat property.ExampleYou can try to run the following code to set the horizontal alignment of an element with JavaScript −Live Demo                 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.             Align Horizontally                function display() {             document.getElementById("myID").style.cssFloat = "right";          }          

How to set the page-break behavior inside an element with JavaScript?

Anvi Jain
Updated on 23-Jun-2020 12:35:33

3K+ Views

Use the pageBreakInside property in JavaScript to set the page-break behavior inside an element. Use the auto property to insert page break inside an element. Use auto or avoid property value to automatically insert page break inside an element, if needed, or avoid a page break, respectively.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior inside an element with JavaScript −           Heading 1       This is demo text.       This is demo text.       This ... Read More

How to set the brightness and contrast of an image with JavaScript?

Sharon Christine
Updated on 23-Jun-2020 12:36:37

4K+ Views

To set the brightness, use the brightness property and for contrast, use the contrast property.ExampleYou can try to run the following code to use image filters with JavaScript −Live Demo           Click below to change the brightness and contrast of the image.       Edit Image                      function display() {             document.getElementById("myID").style.filter = "brightness(50%)";             document.getElementById("myID").style.filter = "contrast(50%)";          }          

How to set the page-break behavior after an element with JavaScript?

Nikitha N
Updated on 23-Jun-2020 12:36:09

857 Views

Use the pageBreakAfter property in JavaScript to set the page-break behavior after an element. Use the always property for page after an element.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior after an element with JavaScript −           Heading 1       This is demo text.       This is demo text.       This if footer text.       Set page-break                function display() {             document.getElementById("myFooter").style.pageBreakAfter = "always";          }          

Set whether the flexible items should wrap or not with JavaScript?

Shubham Vora
Updated on 15-Nov-2022 10:33:40

182 Views

In this tutorial, let us look at the way to set whether the flexible items should wrap or not with JavaScript. We can use the flex-wrap property in JavaScript to set the item wrap value. Let us look into this in brief. Using the Style flex-wrap Property The flex-wrap property defines whether to wrap the items within a container element. The items must be flexible for the flex-wrap property to work. The default value is nowrap. Users can follow the syntax below to use the flex-wrap property. Syntax object.style.flexWrap = "nowrap|wrap|wrap-reverse|initial|inherit" The syntax above sets the flex-wrap value to ... Read More

How to know whether the border and background of empty cells are hidden or not with JavaScript?

Shubham Vora
Updated on 12-Oct-2022 08:36:28

241 Views

In this tutorial, we will learn how to know whether the border and background of empty cells are hidden or not with JavaScript. The JavaScript programming language can be used to create and modify DOM elements. There are two ways to incorporate HTML elements like tables into an HTML document. The first involves adding the HTML table tag straight to our HTML webpage, while the second involves writing the entire table as JavaScript code. The second approach is the most frequently used to create and include tables in the DOM. The tr abbreviation indicates the table row. This represents the ... Read More

Set how the item will shrink relative to the rest with JavaScript?

Shubham Vora
Updated on 15-Nov-2022 10:30:43

310 Views

In this tutorial, let us look at the way to set how much the item will shrink relative to the rest of the elements in JavaScript. To set item shrink relative to the rest of the elements, we can utilize JavaScript's flexShrink property. Let's take a quick look at this. Using the Styel flexShrink Property The flexShrink property specifies how much a flex item will shrink according to the other items in the same container. The element must be flexible for the flexShrink property to function. The property's value functions as a ratio. For instance, 2:3 sets 2 to the ... Read More

Advertisements