DEV Community

Vinayagam
Vinayagam

Posted on • Edited on

About HTML

Here are simple HTML and CSS questions with answers. You can use them in a blog or practice section.


HTML & CSS – Questions and Answers

1️⃣ What is HTML?

Answer:
HTML (HyperText Markup Language) is the standard language used to create and structure content on web pages.


2️⃣ What is CSS?

Answer:
CSS (Cascading Style Sheets) is used to style and design web pages, such as changing colors, fonts, spacing, and layout.


3️⃣ What is the purpose of the <html> tag?

Answer:
The <html> tag is the root element of an HTML document and contains all the content of the webpage.


4️⃣ What is the <head> tag used for?

Answer:
The <head> tag contains metadata about the webpage, such as the title, links to CSS files, and other information not displayed on the page.


5️⃣ What is the <body> tag?

Answer:
The <body> tag contains the visible content of the webpage, such as text, images, links, and videos.


6️⃣ What is a heading tag in HTML?

Answer:
Heading tags (<h1> to <h6>) are used to define headings and titles on a webpage.

Example:

<h1>Main Title</h1>
<h2>Sub Title</h2>
Enter fullscreen mode Exit fullscreen mode

7️⃣ What is a paragraph tag?

Answer:
The <p> tag is used to define a paragraph of text.

Example:

<p>This is a paragraph.</p>
Enter fullscreen mode Exit fullscreen mode

8️⃣ What is a link in HTML?

Answer:
A link connects one webpage to another and is created using the <a> tag.

Example:

<a href="https://example.com">Visit Website</a>
Enter fullscreen mode Exit fullscreen mode

9️⃣ What is the purpose of CSS?

Answer:
CSS is used to control the appearance and layout of a webpage, including colors, fonts, spacing, and positioning.


🔟 What are the three types of CSS?

Answer:

  1. Inline CSS – applied directly inside an HTML tag
  2. Internal CSS – written inside the <style> tag in the <head> section
  3. External CSS – written in a separate .css file

1️⃣1️⃣ What is a CSS selector?

Answer:
A CSS selector is used to select HTML elements and apply styles to them.

Example:

p {
  color: blue;
}
Enter fullscreen mode Exit fullscreen mode

1️⃣2️⃣ What is the difference between class and id?

Answer:

Class ID
Can be used for multiple elements Used for only one element
Written as .className in CSS Written as #idName in CSS

1️⃣3️⃣ What is the <div> tag?

Answer:
The <div> tag is a container used to group HTML elements and apply styles using CSS.


1️⃣4️⃣ What is margin in CSS?

Answer:
Margin is the space outside an element that separates it from other elements.


1️⃣5️⃣ What is padding in CSS?

Answer:
Padding is the space inside an element between the content and the border.


Top comments (0)