Categories
HTML

How to force browser to download image files on click with HTML?

To force browser to download image files on click with HTML, we add the download attribute.

For instance, we write

<a href="/path/to/image.png" download> download </a>

to add the download attribute to make the image at the path download instead of opening it.

Categories
HTML

How to stop an input field in a form from being submitted with HTML?

To stop an input field in a form from being submitted with HTML, we remove the name attribute from the input.

For instance, we write

<input type="text" id="in-between" />

to add an input without the name attribute to stop it from being submitted.

Categories
HTML

How to use complex HTML with Twitter Bootstrap’s Tooltip?

To use complex HTML with Twitter Bootstrap’s Tooltip, we set the data-html attribute to true.

For instance, we write

<span
  rel="tooltip"
  data-toggle="tooltip"
  data-html="true"
  data-title="<table><tr><td style='color:red;'>complex</td><td>HTML</td></tr></table>"
>
  hover over me
</span>

to set the data-html attribute to true to let us add HTML as the tooltip’s content.

And we set the data-title attribute to the tooltip content.

Categories
HTML

How to select multiple files with file input with HTML?

To select multiple files with file input with HTML, we add the multiple attribute to the file input.

For instance, we write

<input type="file" name="filefield" multiple="multiple" />

to add the multiple attribute to the file input to let us select multiple files from the file selection dialog.

Categories
HTML

How to stop Enter key from triggering button click with JavaScript?

To stop Enter key from triggering button click with JavaScript, we set the type attribute of the button to button.

For instance, we write

<button type="button">click me</button>

to add a button with type attribute button to stop pressing enter from trigger a button click.