HTML Basics - Questions and Answers
1. What is HTML?
HTML is a markup language used to create webpages.
2. What is the full form of HTML?
HyperText Markup Language.
3. What are tags in HTML?
Tags are keywords used to define HTML elements.
4. Give examples of HTML tags.
<p>, <h1>, <img>, <a>, <br>, <b>.
5. What are elements in HTML?
Elements are the building blocks of HTML that contain content and tags.
6. What is the root element in HTML?
The <html> tag is the root element of an HTML document.
7. What is the use of <head> tag?
It contains metadata, links, title, and scripts.
8. What is the use of <body> tag?
It holds the visible content of the webpage.
9. What are heading tags?
Tags from <h1> to <h6> used for headings.
10. Which tag is used for paragraphs?
The <p> tag.
11. Which tag is used for a line break?
The <br> tag.
12. How to make text bold, italic, and underlined?
Use <b>, <i>, and <u> tags.
13. Which tag is used to highlight text?
The <mark> tag.
14. Which tags are used for superscript and subscript?
<sup> for superscript, <sub> for subscript.
15. Which tag adds a horizontal line?
The <hr> tag.
16. What are empty elements?
Tags that don’t need a closing tag, like <br> and <hr>.
17. Give an example of an empty element.
<img> or <input>.
18. Where is the title tag placed?
Inside the <head> section.
19. What are attributes in HTML?
Attributes provide extra information about elements.
20. Which tag is used to insert an image?
The <img> tag.
21. Name 4 attributes of the <img> tag.
src, alt, width, height.
22. What is the use of the alt attribute?
It provides alternative text if the image doesn’t load.
23. What is the use of the title attribute?
It shows a tooltip when hovering over the element.
24. Which attribute sets the source of an image?
The src attribute.
25. Which tag is used to create a hyperlink?
The <a> tag.
26. Which attribute sets the hyperlink path?
The href attribute.
27. How to open a link in a new tab?
Use target="_blank" in the <a> tag.
28. Which attribute is used to create a bookmark?
The id attribute (used with #id in links).
29. Write a simple hyperlink tag.
<a href="https://example.com">Visit</a>
30. Write an image tag with alt text.
<img src="image.jpg" alt="Sample Image">
CSS Basics - Questions and Answers
1. What is CSS?
CSS is used to style and design HTML elements.
2. What is the full form of CSS?
Cascading Style Sheets.
3. What is the syntax of CSS?
selector { property: value; }
4. Give an example of a CSS selector.
h1 { color: blue; }
5. Name 5 CSS properties and their uses.
color, font-size, background-color, text-align, border
6. How to change the text color of a heading?
h1 { color: red; }
7. How to change background color?
body { background-color: lightblue; }
8. How to change font size?
p { font-size: 20px; }
9. How to change font family?
p { font-family: Arial; }
10. How to change text alignment?
p { text-align: center; }
11. What are different types of selectors?
Element, ID, Class, Universal, Group selectors.
12. How to use ID selector in CSS?
#header { color: green; }
13. How to use class selector in CSS?
.title { font-size: 22px; }
14. Which HTML element is used as a text container?
<div>
15. What are the 3 ways to apply CSS?
Inline, Internal, External.
16. What is external styling?
CSS is written in a separate file and linked to HTML.
17. What is internal styling?
CSS is written in a <style> tag in the HTML file.
18. What is inline styling?
CSS is added inside HTML tags using the style attribute.
19. Which CSS property changes text case?
text-transform
20. CSS for bold, italic, and underline text?
font-weight: bold;
, font-style: italic;
,
text-decoration: underline;
21. How to add text shadow in CSS?
text-shadow: 2px 2px gray;
22. What are CSS color methods?
Color names, RGB, HEX codes.
23. What are background methods in CSS?
background-color, background-image, background-gradient.
24. How to make background full size?
background-size: cover;
25. What are different gradient types?
Linear, Radial, Conic.
26. How to set a background image?
body { background-image: url('image.jpg'); }
27. How to set a radial gradient background?
background: radial-gradient(circle, red, yellow);
28. What property repeats a background image?
background-repeat
29. How to position background image?
background-position: center;
30. How to fix background image while scrolling?
background-attachment: fixed;