Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Attributes

0/1

HTML Paragraphs

0/1

HTML Formatting

0/1

HTML Comments

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML Symbols

0/1
Text lesson

The autofocus Attribute

The input autofocus attribute dictates that an input field should automatically receive focus upon page load.

Example

Ensure that the “First name” input field receives focus automatically when the page loads.

<form>
  <label for=”fname”>First name:</label><br>
  <input type=”text” id=”fname” name=”fname” autofocus><br>
  <label for=”lname”>Last name:</label><br>
  <input type=”text” id=”lname” name=”lname”>
</form>

The height and width Attributes

The height and width attributes of an <input type=”image”> element determine its height and width.

Tip: It’s essential to specify both the height and width attributes for images. When both are set, the required space for the image is reserved upon page load. Without these attributes, the browser cannot determine the image size and won’t reserve the necessary space, leading to potential layout shifts during loading as images load.

Example

Specify an image as the submit button, providing height and width attributes:

<form>
  <label for=”fname”>First name:</label>
  <input type=”text” id=”fname” name=”fname”><br><br>
  <label for=”lname”>Last name:</label>
  <input type=”text” id=”lname” name=”lname”><br><br>
  <input type=”image” src=”img_submit.gif” alt=”Submit” width=”48″ height=”48″>
</form>