HTML DOM Pre width Property
The HTML DOM Pre width Property is used to set or return the value of the width attribute of the <pre> element.
Syntax:
- It returns a pre width Property.
preObject.width
- It is used to set the pre width property.
preObject.width = "pixels/%";
Property Values:
- pixels: It sets the width of a predetermined text in terms of pixels.
- %: It sets the width of predetermined text in terms of percentage (%).
Return Values: It returns a numeric value that represents the width of the <pre> element.
Example 1: This example returns the width property of a pre element.
HTML
<!DOCTYPE html> < html > < head > < title > HTML DOM Input Text minLength Property </ title > </ head > < body style = "text-align:center;" > < h1 >w3wiki</ h1 > < h2 >DOM Input Text minLength Property</ h2 > < form id = "myBeginner" > < input type = "text" id = "text_id" minlength = "6" name = "Beginner" pattern = "[A-Za-z]{3}" > </ form > < br > < button onclick = "myBeginner()" > Click Here! </ button > < p id = "GFG" style = "font-size:20px;" ></ p > <!-- Script to return the minLength Property--> < script > function myBeginner() { let txt = document.getElementById( "text_id").minLength; document.getElementById( "GFG").innerHTML = txt; } </ script > </ body > </ html > |
Output:
Example 2: Below code is to set the pre width property.
HTML
<!DOCTYPE html> < html > < head > < title > HTML DOM Input Text minLength Property </ title > </ head > < body style = "text-align:center;" > < h1 >w3wiki</ h1 > < h2 >DOM Input Text minLength Property</ h2 > < form id = "myBeginner" > < input type = "text" id = "text_id" minlength = "6" name = "Beginner" pattern = "[A-Za-z]{3}" > </ form > < br > < button onclick = "myBeginner()" > Click Here! </ button > < p id = "GFG" style = "font-size:20px;" ></ p > <!-- Script to set the minLength Property--> < script > function myBeginner() { let txt = document.getElementById( "text_id").minLength - "23"; document.getElementById( "GFG").innerHTML = txt; } </ script > </ body > </ html > |
Output: