Skip to content

Commit

Permalink
Merge pull request #216 from nsundriyal62/html_interview_question
Browse files Browse the repository at this point in the history
interview question of html
  • Loading branch information
Vishal-raj-1 authored Oct 15, 2023
2 parents fc30587 + 148beee commit 5358c93
Showing 1 changed file with 152 additions and 5 deletions.
157 changes: 152 additions & 5 deletions content/batch/learn/html/basic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,159 @@ Want to improve this page? Raise a issue on [@github](https://github.com/ManishB

</TabsContent>

<TabsContent value="InterviewQuestion">
Interview Questions on HTML
</TabsContent>

<TabsContent value="interview">
Interview Questions on HTML

# 📌📄 HTML Theory Questions

### Q1 What is HTML?
- HTML stands for Hyper Text Markup Language. It is the standard markup language for documents designed to be displayed in a web browser.

### Q2 What are HTML tags?
- HTML tags are special codes that are used to define elements on a web page. Tags are placed inside angle brackets (`<` and `>`) and usually come in pairs: an opening tag and a closing tag.

### Q3 What is an HTML element?
- An HTML element is defined by a start tag, some content, and an end tag. The start tag is the name of the element enclosed in angle brackets. The end tag has a forward slash before the name.

### Q4 What is the difference between an HTML element and an HTML attribute?
- An HTML element is a part of the HTML document that represents a specific piece of content. An HTML attribute provides additional information about an element, modifying its behavior or appearance.

### Q5 What is the purpose of the DOCTYPE declaration?
- The DOCTYPE declaration is used to specify the version of HTML that the document is using. It is placed at the very beginning of an HTML document and helps browsers render the page correctly.

### Q6 What is the role of the head and body elements in an HTML document?
- The `head` element contains meta-information about the document, such as its title, character set, and links to stylesheets and scripts. The `body` element contains the content of the document that is displayed in the web browser.

### Q7 What are HTML forms used for?
- HTML forms are used to collect user input. They can contain various types of input elements like text fields, checkboxes, radio buttons, submit buttons, etc.

### Q8 What is the role of the alt attribute in an img element?
- The `alt` attribute provides alternative text for an image if it cannot be displayed. This text is displayed in place of the image and is also used by screen readers for accessibility.

### Q9 What is the purpose of the anchor (a) tag?
- The `a` tag, or anchor tag, is used to create hyperlinks in an HTML document. It can be used to link to another document or resource, both within the same website and externally.

### Q10 What is the role of the div and span elements?
- The `div` and `span` elements are generic container elements. They are used to group and style elements using CSS. `div` is a block-level element, while `span` is an inline-level element.



# 📌💻 HTML Coding Questions

## Q1 Create a simple HTML page

### Question
Create a simple HTML page with a heading, a paragraph, and a list of items.

### Answer
```html
<!DOCTYPE html>
<html>
<head>
<title>My Simple Page</title>
</head>
<body>
<h1>Welcome to My Page</h1>
<p>This is a simple HTML page.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</body>
</html>
```

## Q2 Create an HTML form

### Question
Create a simple HTML form with a text input, a password input, a checkbox, and a submit button.

### Answer
```html
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username">

<label for="password">Password:</label>
<input type="password" id="password" name="password">

<label>
<input type="checkbox" id="subscribe" name="subscribe">
Subscribe to newsletter
</label>

<input type="submit" value="Submit">
</form>
```

## Q3 Create a table with HTML

### Question
Create an HTML table with three rows and three columns.

### Answer
```html
<table>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
<td>Row 1, Column 3</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
<td>Row 2, Column 3</td>
</tr>
<tr>
<td>Row 3, Column 1</td>
<td>Row 3, Column 2</td>
<td>Row 3, Column 3</td>
</tr>
</table>
```

## Q4 Create an HTML document with an image

### Question
Create an HTML document with a heading and an image.

### Answer
```html
<!DOCTYPE html>
<html>
<head>
<title>My HTML Page with an Image</title>
</head>
<body>
<h1>Welcome to My Page</h1>
<img src="example.jpg" alt="An example image">
</body>
</html>
```

## Q5 Create an HTML document with links

### Question
Create an HTML document with a list of links to different websites.

### Answer
```html
<!DOCTYPE html>
<html>
<head>
<title>My HTML Page with Links</title>
</head>
<body>
<h1>Welcome to My Page</h1>
<ul>
<li><a href="https://www.example1.com">Example 1</a></li>
<li><a href="https://www.example2.com">Example 2</a></li>
<li><a href="https://www.example3.com">Example 3</a></li>
</ul>
</body>
</html>
```

</TabsContent>

<TabsContent value="playground">
Expand Down

0 comments on commit 5358c93

Please sign in to comment.