top of page
Writer's pictureYatendra Awana

Basic HTML Tags


1. What does the <html> tag define?

Answer: It defines the root of an HTML document, containing all other HTML elements.

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

Answer: It contains metadata about the document, such as the title, character set, and links to stylesheets or scripts.

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

Answer: The <title> tag.

4. How do you create a paragraph in HTML?

Answer: Use the <p> tag. Example: <p>This is a paragraph.</p>.

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

Answer: The <br> tag.

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

Answer: Use the <hr> tag.

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

Answer: It defines the main content of the HTML document displayed in the browser.

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

Answer: Use <h1> to <h6> tags, where <h1> is the largest and <h6> is the smallest. Example: <h1>Main Heading</h1>.

9. Which tag is used to make text bold?

Answer: The <b> or <strong> tag.

10. How do you italicize text in HTML?

Answer: Use the <i> or <em> tag.

________________________________________

Links and Navigation

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

Answer: It is used to create hyperlinks.

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

Answer: Use the target="_blank" attribute in the <a> tag.

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

Answer: It specifies the URL of the link.

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

Answer: Use an id on the target element and link to it with #id. Example: <a href="#section1">Go to Section 1</a> and <div id="section1">...</div>.

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

Answer: Absolute links specify the full URL (e.g., https://example.com), while relative links specify a path relative to the current page (e.g., about.html).

________________________________________

Images and Multimedia

16. How do you insert an image in HTML?

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

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

Answer: It provides alternative text for the image if it cannot be displayed.

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

Answer: The height and width attributes. Example: <img src="image.jpg" height="200" width="300">.

19. How do you embed a video in HTML?

Answer: Use the <video> tag with the src attribute. Example: <video src="video.mp4" controls></video>.

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

Answer: The <audio> tag is used for sound files, while the <video> tag is used for video files.

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

Answer: Add text content inside the <audio> tag. Example:

html

Copy code

<audio src="audio.mp3" controls>Your browser does not support audio.</audio>

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

Answer: The autoplay attribute.

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

Answer: Use the controls attribute.

________________________________________

Forms and Inputs

24. How do you create a form in HTML?

Answer: Use the <form> tag. Example:

html

Copy code

<form action="submit.php" method="post">

<input type="text" name="username">

<button type="submit">Submit</button>

</form>

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

Answer: It specifies the URL to send the form data to.

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

Answer: Use <input type="text">.

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

Answer: It specifies the type of input (e.g., text, password, email).

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

Answer: Use <input type="password">.

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

Answer: Add the required attribute to the input field.

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

Answer: The <select> tag with <option> elements.

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

Answer: Use <input type="checkbox"> for each option.

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

Answer: A radio button allows only one selection in a group, while checkboxes allow multiple selections.

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

Answer: Use <input type="submit"> or <button type="submit">.

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

Answer: It improves accessibility by associating labels with form controls.

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

Answer: Use the value attribute.

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

Answer: It displays a short hint inside the input field.

________________________________________

Tables

37. How do you create a table in HTML?

Answer: Use the <table> tag with <tr> for rows and <td> for cells.

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

Answer: It defines the header section of a table.

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

Answer: Use the <tr> tag.

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

Answer: <td> defines table cells, while <th> defines header cells with bold and centered text by default.

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

Answer: The <caption> tag.

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

Answer: Use the colspan attribute in a <td> tag.

43. How do you merge two or more cells in a table vertically?

Answer: Use the rowspan attribute in a <td> tag.

________________________________________

Lists

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

Answer: Ordered lists (<ol>) are numbered, while unordered lists (<ul>) are bulleted.

45. How do you create a bulleted list?

Answer: Use <ul> with <li> elements.

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

Answer: Use <ol> with <li> elements.

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

Answer: The <li> tag.

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

Answer: Place one list inside another <li> element.

________________________________________

Semantic HTML and Structural Tags

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

Answer: It defines the header of a page or section, often containing navigation links or logos.

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

Answer: The <footer> tag defines the footer of a page or section, often containing copyright or contact information.

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

Answer: It defines the main content of the page, excluding headers, footers, and navigation.

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

Answer: The <article> tag defines independent content that could stand alone, while the <section> tag defines a thematic grouping of content within a document.

53. What is the purpose of the <nav> tag?

Answer: It is used to define navigation links.

54. What is the <aside> tag used for?

Answer: It defines content that is tangentially related to the main content, like sidebars.

55. What does the <figure> tag represent?

Answer: It represents self-contained content, often used with <img>, <video>, or <figcaption> tags.

56. What is the use of the <figcaption> tag?

Answer: It provides a caption or description for the content inside the <figure> tag.

57. How does the <mark> tag work?

Answer: It highlights or marks text as important.

________________________________________

Meta Tags and Character Encoding

58. What is the purpose of the <meta> tag?

Answer: It provides metadata about the HTML document, such as character encoding or author information.

59. Which <meta> tag is used to specify the character encoding of the document?

Answer: The <meta charset="UTF-8"> tag.

60. How do you add keywords for search engines using <meta>?

Answer: Use the <meta name="keywords" content="keyword1, keyword2, keyword3"> tag.

61. What does the <meta name="viewport"> tag do?

Answer: It ensures proper scaling on mobile devices by setting the viewport width.

________________________________________

Other HTML Tags and Attributes

62. What is the purpose of the <style> tag?

Answer: It defines internal CSS styles within the HTML document.

63. What is the purpose of the <script> tag?

Answer: It is used to embed JavaScript code in the HTML document.

64. Which tag is used to create a comment in HTML?

Answer: The <!-- comment --> tag.

65. How do you make text appear as superscript in HTML?

Answer: Use the <sup> tag.

66. How do you make text appear as subscript in HTML?

Answer: Use the <sub> tag.

67. What is the purpose of the class attribute?

Answer: It assigns a class to an HTML element for CSS or JavaScript targeting.

68. What is the id attribute used for?

Answer: It assigns a unique identifier to an element, allowing it to be targeted by CSS or JavaScript.

69. How do you group elements in HTML?

Answer: Use the <div> or <span> tags. <div> is block-level, while <span> is inline.

70. What is the use of the data-* attribute in HTML?

Answer: It allows you to store custom data in HTML elements.

________________________________________

HTML Table Styling

71. Which attribute is used to set the table border width?

Answer: The border attribute in the <table> tag.

72. How do you make a cell in a table span multiple columns?

Answer: Use the colspan attribute.

73. How do you make a cell in a table span multiple rows?

Answer: Use the rowspan attribute.

74. How can you set a table caption in HTML?

Answer: Use the <caption> tag. Example: <caption>Table Title</caption>.


5 views0 comments

Recent Posts

See All

Comments


bottom of page