top of page

HTML Basic Tags and Their Usage

Writer's picture: Yatendra AwanaYatendra Awana

  1. What does the <html> tag define?

    • The <html> tag defines the root of an HTML document and contains all other elements.

  2. What is the purpose of the <head> tag?

    • The <head> tag contains metadata, links to external resources, and settings for the document, such as the title, CSS, or JavaScript.

  3. Which tag is used to display the title of the page on the browser tab?

    • The <title> tag inside the <head> is used to define the title of the page.

  4. How do you create a paragraph in HTML?

    • Use the <p> tag to create a paragraph. Example: <p>This is a paragraph.</p>.

  5. Which tag is used to create a line break in HTML?

    • The <br> tag is used to insert a line break.

  6. How do you define a horizontal line in an HTML page?

    • Use the <hr> tag to define a horizontal line.

  7. What is the <body> tag used for?

    • The <body> tag contains the content of an HTML document that is visible on the webpage.

  8. How do you display a heading in HTML? Name the heading levels.

    • Use <h1> to <h6> tags for headings, with <h1> being the largest and <h6> the smallest.

  9. Which tag is used to make text bold?

    • Use the <b> tag for bold text. Example: <b>Bold Text</b>.

  10. How do you italicize text in HTML?

    • Use the <i> tag for italicized text. Example: <i>Italic Text</i>.

Links and Navigation

  1. What is the purpose of the <a> tag in HTML?

    • The <a> tag is used to create hyperlinks.

  2. How do you make a link open in a new tab?

    • Add target="_blank" to the <a> tag. Example: <a href="url" target="_blank">Link</a>.

  3. What does the href attribute specify in the <a> tag?

    • The href attribute specifies the URL of the link.

  4. How do you link to a section within the same page?

    • Use id on the target section and link to it with #id. Example: <a href="#section">Go to Section</a>.

  5. What is the difference between absolute and relative links in the <a> tag?

    • Absolute links contain the full URL (e.g., https://example.com).


      Relative links refer to a file path (e.g., images/photo.jpg).

Images and Multimedia

  1. How do you insert an image in HTML?

    • Use the <img> tag with the src attribute. Example: <img src="image.jpg" alt="Image">.

  2. What is the purpose of the alt attribute in an <img> tag?

    • The alt attribute provides alternative text if the image fails to load.

  3. Which attribute is used to set the height and width of an image?

    • Use the height and width attributes in the <img> tag.

  4. How do you embed a video in HTML?

    • Use the <video> tag with a src attribute or <source> tag. Example:

      html

      Copy code

      <video controls> <source src="video.mp4" type="video/mp4"> </video>

  5. What is the difference between <audio> and <video> tags?

    • <audio> embeds sound, while <video> embeds video.

  6. How do you add a fallback message in case a browser does not support the <audio> tag?

    • Place the message inside the <audio> tag:

      html

      Copy code

      <audio controls> Your browser does not support the audio element. </audio>

  7. Which attribute in the <video> tag enables autoplay?

    • The autoplay attribute.

  8. How do you add a control bar to an <audio> or <video> element?

    • Add the controls attribute to the tag.

Forms and Inputs

  1. How do you create a form in HTML?

    • Use the <form> tag. Example: <form action="submit.php"></form>.

  2. What is the purpose of the action attribute in a <form> tag?

    • The action attribute specifies the URL to which the form data is sent.

  3. How do you create a text input field in a form?

    • Use <input type="text">.

  4. What is the purpose of the type attribute in the <input> tag?

    • It defines the type of input (e.g., text, email, password).

  5. How do you create a password field in HTML?

    • Use <input type="password">.

  6. How can you make a field mandatory in a form?

    • Add the required attribute to the input.

  7. Which tag is used to create a drop-down list?

    • Use the <select> tag with <option> elements.

  8. How do you create a group of checkboxes in HTML?

    • Use <input type="checkbox"> for each item.

  9. What is the difference between a radio button and a checkbox?

    • Checkbox: Allows selecting multiple options.


      Radio button: Allows selecting only one option within a group.

  10. How do you add a submit button to a form?

    • Use <input type="submit"> or <button type="submit">.

  11. What is the purpose of the <label> tag in forms?

    • It associates a label with an input for better accessibility.

  12. How do you define a default value for an input field?

    • Use the value attribute in <input>.

  13. What is the purpose of the placeholder attribute in the <input> tag?

    • It displays a hint inside the input field.

Tables

  1. How do you create a table in HTML?

    • Use the <table> tag along with <tr> and <td>.

  2. What is the purpose of the <thead> tag?

    • It defines the header section of a table.

  3. How do you define a row in a table?

    • Use the <tr> tag.

  4. What is the difference between <td> and <th> tags?

    • <td> defines a data cell, while <th> defines a header cell.

  5. Which tag is used to add a caption to a table?

    • Use the <caption> tag.

  6. How do you merge two or more cells in a table horizontally?

    • Use the colspan attribute in <td>.

Lists

  1. What is the difference between ordered and unordered lists?

    • Ordered lists (<ol>) are numbered.


      Unordered lists (<ul>) use bullet points.

  2. How do you create a bulleted list?

    • Use the <ul> tag with <li> items.

  3. How do you create a numbered list in HTML?

    • Use the <ol> tag with <li> items.

  4. Which tag is used to define an item in a list?

    • Use the <li> tag.

  5. How do you create a nested list in HTML?

    • Place <ul> or <ol> inside an <li>.

Semantic HTML and Structural Tags

  1. What is the purpose of the <header> tag?

    • It defines the introductory content or navigation links.

  2. How does the <footer> tag differ from the <header> tag?

    • The <footer> tag is used for closing content like copyright, links, or contact information.

  3. What is the <main> tag used for?

    • It contains the primary content of a webpage.

  4. How is the <article> tag different from the <section> tag?

    • <article> represents standalone content, while <section> groups related content.

  5. Which tag is used to define navigation links in a web page?

    • Use the <nav> tag.

12 views0 comments

Recent Posts

See All

Comments


bottom of page