Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
HTML Articles
Page 144 of 151
How to create a context menu for an element in HTML5?
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 MoreExecute a script when a user is pressing a key in HTML?
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 MoreHow to specify that the target will be downloaded when a user clicks on the hyperlink in HTML?
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 MoreHow to execute the script when the page has finished parsing in HTML?
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 MoreHow do we display the visible width of a text area in HTML?
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 MoreHow do we display the thickness of the border of an element in HTML?
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 MoreHow do we specify that the audio/video will start playing as soon as it is ready in HTML?
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 MoreHow to specify that the element should automatically get focus when the page loads in HTML?
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 MoreHow to set the script to be executed asynchronously in HTML?
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 MoreHow to include an alternate text when the original element fails to display in HTML?
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