HTML Articles

Page 144 of 151

How to create a context menu for an element in HTML5?

Ramu Prasad
Ramu Prasad
Updated on 03-Mar-2020 593 Views

Use the contextmenu attribute in HTML5 to create a context menu for an element. A context menu generates when a user right-clicks. ExampleYou can try to run the following code to create a context menu −           HTML menuitem Tag                        Right click inside here....                                                                              

Read More

Execute a script when a user is pressing a key in HTML?

Chandu yadav
Chandu yadav
Updated on 03-Mar-2020 398 Views

Use the onkeydown attribute. The onkeydown attribute triggers when the user is pressing a key.ExampleYou can try to run the following code to execute a script on pressing a key −           Press a key inside the textbox.                      function display() {             alert("You pressed a key!");          }          

Read More

How to specify that the target will be downloaded when a user clicks on the hyperlink in HTML?

Nikitha N
Nikitha N
Updated on 03-Mar-2020 205 Views

Use the download attribute to set the file to download on click of the hyperlink. Set the value of the attribute to the name of the downloaded file, for example, image.Example           if statement in Java       The following is an image explaining the concept if if-statmement in Java (Click to download):                                

Read More

How to execute the script when the page has finished parsing in HTML?

Rishi Rathor
Rishi Rathor
Updated on 03-Mar-2020 434 Views

Use the defer attribute to execute the script when the page has finished parsing in HTML.Firstly, add a js file.Let us give it a name, new.js,function sayHello() {    alert("Hello World") }ExampleLet’s add the HTML code now and execute the above script −                         This is demo text.    

Read More

How do we display the visible width of a text area in HTML?

Arjun Thakur
Arjun Thakur
Updated on 03-Mar-2020 226 Views

Use the cols attribute in HTML to display the visible width of a textarea. You can try to run the following code to implement cols attribute −Example                    This is a demo paragraph. This is a demo paragraph.          This is a demo paragraph. This is a demo paragraph.          

Read More

How do we display the thickness of the border of an element in HTML?

Chandu yadav
Chandu yadav
Updated on 02-Mar-2020 199 Views

Use the border attribute in HTML to display the thickness of the border.Note − This attribute is not supported in HTML5.ExampleYou can try to run the following code to learn how to implement border attribute in HTML −           Cricketers                Name                       Sachin Tendulkar                                 Virat Kohli                     Use CSS instead, since the border attribute deprecated in HTML5.                    table, th, td {             border: 1px solid black;          }                     Cricketers                Indian Cricketers          Name                       Sachin Tendulkar                                 Virat Kohli                    

Read More

How do we specify that the audio/video will start playing as soon as it is ready in HTML?

Ankith Reddy
Ankith Reddy
Updated on 02-Mar-2020 373 Views

Use the autoplay attribute to set that the audio or video will start playing automatically as the page loads.ExampleYou can try to run the following code to implement autoplay attribute in HTML −                                        Your browser does not support the video element.          

Read More

How to specify that the element should automatically get focus when the page loads in HTML?

mkotla
mkotla
Updated on 02-Mar-2020 304 Views

Use the autofocus attribute to specify that the element should get focus automatically on page load in HTML −ExampleYou can try to run the following code to learn how to implement autofocus attribute in HTML −           Click on the below button to generate an alert box.       Result    

Read More

How to set the script to be executed asynchronously in HTML?

Abhinanda Shri
Abhinanda Shri
Updated on 02-Mar-2020 167 Views

Use the async attribute to set the script to execute asynchronously as and when it is available. It only uses the external script.Firstly, add a js file. Let us give it a name, new.js,function sayHello() {    alert("Hello World") }Let’s add the HTML code now and execute the above script −                         This is demo text.    

Read More

How to include an alternate text when the original element fails to display in HTML?

Giri Raju
Giri Raju
Updated on 02-Mar-2020 182 Views

Use the alt attribute to add alternative text for an image. If the user fails to view it (loading issue), then the same text will be visible. In addition, the attribute helps screen readers in reading the content to the user.ExampleYou can try to run the following code to implement alt attribute in HTML −           HTML alt attribute               Simple Image Insert          

Read More
Showing 1431–1440 of 1,508 articles
« Prev 1 142 143 144 145 146 151 Next »
Advertisements