HTML and CSS Complete Question Answers
PART - A
1) What is HTML? Give the basic structure of an HTML page.
HTML (HyperText Markup Language) is a standard language used to create and design web pages.
It structures web
content using various tags like headings, paragraphs, lists, and links. HTML elements are the
building blocks
of web pages, which browsers interpret to display the content properly.
Basic Structure of an HTML Page:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Welcome to My Web Page</h1>
<p>This is a simple HTML page.</p>
</body>
</html>
2) Explain the HTML elements for creating ordered and unordered lists.
Lists in HTML help organize information systematically. There are two main types:
1. Ordered List (<ol>) - Items are numbered (1, 2, 3).
2. Unordered List (<ul>) - Items use bullet points.
Example HTML Document:
<!DOCTYPE html>
<html>
<head>
<title>HTML Lists</title>
</head>
<body>
<h2>Ordered List</h2>
<ol>
<li>Wake up</li>
<li>Brush your teeth</li>
<li>Have breakfast</li>
</ol>
<h2>Unordered List</h2>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Grapes</li>
</ul>
</body>
</html>
3) Explain the CSS Box Model. Provide an example of applying a solid border of 5px width in red
color.
The CSS Box Model describes how HTML elements are structured as rectangular boxes. It consists
of:
- Content: The actual text or image inside the element.
- Padding: Space between content and the border.
- Border: The outer line surrounding the padding.
- Margin: Space outside the border separating elements.
Example CSS:
.box {
border: 5px solid red;
padding: 10px;
margin: 20px;
Example HTML:
<div class="box">This is a box with a red border.</div>
4) List and explain different ways of specifying borders using CSS.
CSS provides different styles for borders:
- Solid: border: 2px solid blue;
- Dotted: border: 2px dotted green;
- Dashed: border: 2px dashed red;
- Double: border: 4px double black;
- Groove: border: 3px groove gray;
PART - B
1) What is CSS? Give the syntax for CSS.
CSS (Cascading Style Sheets) is used to style HTML elements. It controls layout, color, font, and
other styles.
Syntax:
selector {
property: value;
Example:
p{
color: blue;
font-size: 18px;
2) Explain the src and href attributes in HTML.
- src: Used in <img> for images. Example: <img src="image.jpg" alt="Image">
- href: Used in <a> for hyperlinks. Example: <a href="https://www.google.com">Visit Google</a>
3) Explain how text shadow can be added using CSS.
CSS text-shadow property allows adding shadows to text.
Syntax:
text-shadow: x-offset y-offset blur-radius color;
Example:
h1 {
text-shadow: 2px 2px 5px gray;
4) Explain how fonts are specified using CSS.
Fonts are specified using font-family, font-size, font-weight, and font-style properties.
Example:
p{
font-family: Arial, sans-serif;
font-size: 16px;
font-weight: bold;
font-style: italic;