Execute a Script When Document is About to be Unloaded in HTML

Nishtha Thakur
Updated on 03-Mar-2020 12:20:33

181 Views

The onbeforeunload event attribute’ fires when the document is ready to be unloaded.ExampleYou can try to run the following code to implement the onbeforeunload attribute −           Close this window or press F5.                function display() {             return "Wanna stay here or leave?";          }          

Set the Language of Track Text Data in HTML

Abhinanda Shri
Updated on 03-Mar-2020 11:25:44

178 Views

Use the srclang attribute to set the language of the track text data in HTML. For subtitles, use this attribute.ExampleYou can try to run the following code to implement srlang attribute −                                                            Your browser does not support the video element.          

Specify Image URL for Different Situations in HTML

Smita Kapse
Updated on 03-Mar-2020 11:25:00

354 Views

Use the srcset attribute to specify the URL of the image to use in different situations in HTML.ExampleYou can try to run the following code to implement srcset attribute. Resize the browser to see different images loading −                                                                

Set the Start Value of an Ordered List in HTML

mkotla
Updated on 03-Mar-2020 11:24:10

479 Views

Use the start attribute to set the start value of an ordered list in HTML i.e.Add the value of where you want to start above.ExampleYou can try to run the following code to implement the start attribute −           HTML ol Tag               Programming Languages Rank Usage:                Java          C++          C          

Include Legal Number Intervals for Input Field in HTML

radhakrishna
Updated on 03-Mar-2020 11:23:06

330 Views

Use the step attribute to include the legal number intervals for an input field in HTML. The HTML input type step attribute sets the legal number intervals. Steps are number steps like 0, 5, 10, 15, 20, etc. The step attribute can be used together with the max and min attributes to create a range of legal values.ExampleYou can try to run the following code to implement step attribute −           HTML input step attribute                                            

Execute a Script When the Element Loses Focus in HTML

Govinda Sai
Updated on 03-Mar-2020 11:11:35

318 Views

Use the onblur attribute execute a script when the element loses focus in HTML. You can try to run the following code to implement onblur attribute −Example           Type text below!       Country:                function display() {             var str = document.getElementById("myid");             str.value = str.value.toUpperCase();          }          

Set the Shape of the Area in HTML

mkotla
Updated on 03-Mar-2020 11:10:57

175 Views

Use the shape attribute to set the shape of the area in HTML. You can try to run the following code to implement shape attribute −Example           HTML shape attribute                                              

Pre-select Option in HTML on Page Load

Jennifer Nicholas
Updated on 03-Mar-2020 11:10:09

170 Views

Use the selected attribute to specify that the option should be pre-selected when page loads in HTML. You can try to run the following code to implement selected attribute −Example           HTML selected attribute               Here's the list of subjects. Select any one:                             Computer Architecture             Java             Discrete Mathematics                    

Specify Styles for Parent and Child Elements in HTML

seetha
Updated on 03-Mar-2020 11:09:27

288 Views

Use the scoped attribute to specify that the styles only apply to the parent element and the element’s child elements −Example                    h2 {             color:yellow;          }                                           h2 {                color:grey;             }                    Grey Heading             Yellow Heading    

Specify Required Fields in HTML Forms

vanithasree
Updated on 03-Mar-2020 11:05:03

792 Views

The required attribute in HTML is used to specify that the element should be filled before the form is submitted. If the field is not filled and the submit button is clicked, an error generates, which fails form submission. The error will be “Please fill out this field”.The required attribute can be used on input, select and textarea element.ExampleYou can try to run the following code to implement readonly attribute −           HTML placeholder attribute               Register                                    

Advertisements