HTML Articles

Page 4 of 151

What is the difference between height and line-height?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 3K+ Views

Height is the vertical measurement of the container, for example, height of a div.Line-height is a CSS property to specify the line height i.e. the distance from the top of the first line of text to the top of the second. It is the space between the lines of two paragraphs.ExampleYou can try to run the following code to learn the difference between height and line height:                    .height {             height: 20px;          }          .lheight { ...

Read More

Add oninput attribute to HTML element with JavaScript?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 643 Views

For this, use the concept of document.getElementById() along with addEventListener(). Following is the JavaScript code −Example Document Enter the value:    document.getElementById('enterValue').addEventListener("input", function () {       console.log('you have entered the value');    }); To run the above program, save the file nameanyName.html(index.html) and right click on the file and select the option open with live server in VS code editor.OutputWhen user enters a value −

Read More

How to embed JavaScript in HTML file?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 593 Views

Following is the code to embed JavaScript in html file −Example Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Embed javascript in html file    let resEle = document.querySelector(".result");    resEle.innerHTML += "Inline javaScript loaded" + ""; script.jsresEle.innerHTML += 'External JavaScript loaded ';OutputThe above code will produce the following output −

Read More

How to disable autocomplete of an HTML input field?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 398 Views

To disable autocomplete of an input field, the code is as follows −Example    input{       font-size: 18px;       padding: 10px;       margin: 10px;       border:1px solid grey;    } Autocomplete on/off Example First name: Last name: Type in the above fields and refresh page to see autocomplete at work OutputThe above code will produce the following output −On typing something in the above fields after submitting the form one time −

Read More

How to turn off spell checking (grammar correction) for HTML form elements?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 195 Views

To turn off spell check for form elements, the code is as follows −Example Disabling Spellcheck Example Your Name: About Yourself Type wrong spelling in the above input field to see spellcheck in action OutputThe above code will produce the following output −On typing something in the input fields −

Read More

How to sort an HTML list using JavaScript?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

To sort an HTML list using JavaScript, the code is as follows −Example Sorting list example Click to sort Giraffe Camel Dog Lion Cheetah Cat    document .getElementsByTagName("button")[0] .addEventListener("click", sortList);    function sortList() {       var list, i, sortFlag, LiEle, sorted;       list = document.querySelector(".animalList");       sortFlag = true;       while (sortFlag) {          sortFlag = false;          LiEle = list.getElementsByTagName("LI");          for (i = 0; i < LiEle.length - 1; i++) {           ...

Read More

How to create a download link with HTML?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 868 Views

To create a download link with HTML, the code is as follows −Example Download Link example Click on the image above to download it OutputThe above code will produce the following output −

Read More

How to display XML in HTML in PHP?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

If the string is pre-formatted, and a plain text representation of the same is needed, it can be wrapped in a HTML tag and html entities can be used to escape the angle brackets. This has been shown below −The string is assigned to a string type and the above is used to show XML in HTML −ExampleOutputThis will produce the following output −           EXAMPLE    

Read More

HTML DOM TouchEvent Object

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 213 Views

The HTML DOM TouchEvent Object represents an event which incurs on interaction with the HTML document elements using touch devices.Here, “TouchEvent” can have the following properties and methods −Property/MethodDescriptionaltKeyItreturns a Booleanvalue corresponding to the state if alt key was pressed when atouch event was firedchangedTouchesItreturns aTouchList object corresponding to a list of all contact pointstriggered on a state change of touch eventsctrlKeyItreturns a Booleanvalue corresponding to the state if ctrl was pressed when a touchevent was firedmetaKeyItreturns a Booleanvalue corresponding to the state if meta was pressed when a touchevent was firedshiftKeyItreturns a Booleanvalue corresponding to the state if shift ...

Read More

HTML DOM Meter value Property

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 165 Views

The HTML DOM Meter value property returns/sets a number corresponding to the value attribute of a element. Use this with high, low, min and max attributes for better results.NOTE: Don’t use as a progress bar but only as a gauge.Following is the syntax −Returning value of the value propertymeterElementObject.valueValue of the value property setmeterElementObject.value = numberLet us see an example of Meter value property −Example Meter value    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;   ...

Read More
Showing 31–40 of 1,508 articles
« Prev 1 2 3 4 5 6 151 Next »
Advertisements