- What is HTML? What is its full name? Please briefly describe the role of HTML in one sentence.
Answer: HTML is Hypertext Markup Language. It is used to create web pages, describing the structure and content of web pages.
- What are tags in HTML? Please give an example.
Answer: Tags are elements in HTML that describe the structure and content of a web page. For example, <p>
a tag represents a paragraph, <img>
which represents an image.
- What are attributes in HTML? Please give an example.
Answer: Attributes are attributes of an HTML tag that describe the behavior and appearance of the tag. For example, the attribute <img src="image.png" alt="A beautiful image">
in src
represents the URL address of the image, and alt
the attribute represents the alternate text of the image.
- What are comments in HTML? Please give an example.
Answer: Comments are text in HTML that is used to explain code to developers. For example, <!-- 这是一个注释 -->
to represent a comment.
- What are heading tags in HTML? Please give an example.
Answer: Title tags are used to create the title of a web page, including <h1>
to <h6>
tags. For example, <h1>这是一个标题</h1>
to indicate a first-level heading.
- What are paragraph tags in HTML? Please give an example.
Answer: Paragraph tags are used to create paragraphs in web pages, including <p>
tags. For example, <p>这是一个段落。</p>
to represent a paragraph.
- What is the image tag in HTML? Please give an example.
Answer: Image tags are used to insert images in web pages, including <img>
tags. For example, <img src="image.png" alt="A beautiful image">
to represent an image tag.
- What is a link tag in HTML? Please give an example.
Answer: Link tags are used to create links in web pages, including <a>
tags. For example, <a href="<https://www.google.com/>">这是一个链接</a>
to represent a link label.
- What are list tags in HTML? Please give an example.
Answer: List tags are used to create lists in web pages, including ordered <ol>
and unordered lists <ul>
. For example, <ul><li>列表项1</li><li>列表项2</li></ul>
to represent an unordered list.
- What are table tags in HTML? Please give an example.
Answer: Table tags are used to create tables in web pages, including <table>
, <tr>
, <td>
and other tags. For example,
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
Represents a table with 4 cells.
- What are form tags in HTML? Please give an example.
Answer: Form tags are used to create forms in web pages, including <form>
, <input>
etc. tags. For example,
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
</form>
Represents a form with one text input box.
- What are style tags in HTML? Please give an example.
Answer: Style tags are used to style web pages, including <style>
tags. For example,
<style>
body {
background-color: #f0f0f0;
}
</style>
Indicates that a gray background is added to the web page.
- What are script tags in HTML? Please give an example.
Answer: Script tags are used to embed scripts in web pages, including <script>
tags. For example,
<script>
alert("Hello, world!");
</script>
Indicates that a message box has popped up in the web page.
- What are metacharacters in HTML? Please give an example.
Answer: Metacharacters are special characters in HTML, including <
, >
, &
and other characters. For example, <
it can be <
represented by .
- What is DOCTYPE in HTML? Please give an example.
Answer: DOCTYPE is used to specify the type and version of the HTML document. For example,
<!DOCTYPE html>
<html>
<head>
<title>这是一个HTML文档</title>
</head>
<body>
<p>这是一个段落。</p>
</body>
</html>
Represents an HTML5 document.
- What are character sets in HTML? Please give an example.
Answer: A character set is used to specify the character encoding in an HTML document. For example,
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>这是一个HTML文档</title>
</head>
<body>
<p>这是一个段落。</p>
</body>
</html>
Represents a UTF-8 encoded HTML document.
- How is the image size specified in HTML? Please give an example.
Answer: The image size can be specified by CSS style or HTML attribute. For example,
<img src="image.png" width="100" height="100">
Represents an image with a width of 100 pixels and a height of 100 pixels.
- How are hyperlinks specified in HTML? Please give an example.
Answer: Hyperlinks can href
specify the URL address of the link through attributes. For example,
<a href="<https://www.google.com/>">这是一个链接</a>
Indicates a link to a Google website.
- Can table cells in HTML be merged? Please give an example.
Answer: Yes. Table cells can be merged via colspan
and rowspan
attributes. For example,
<table>
<tr>
<td colspan="2">合并两个单元格</td>
</tr>
<tr>
<td>单元格1</td>
<td rowspan="2">合并两个单元格</td>
</tr>
<tr>
<td>单元格2</td>
</tr>
</table>
Represents a table with merged cells.
- Where can forms in HTML be submitted? Please give an example.
Answer: A form can be submitted to a URL address on the server or to a JavaScript function. For example,
<form action="submit.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<button type="submit">提交</button>
</form>
Represents a form that submits a form to submit.php
a page.
- What types of input boxes can be in a form in HTML? Please give an example.
Answer: The input box in the form can be a text input box, a password input box, a radio box, a check box, a drop-down list box, etc. For example,
<form>
<label for="username">用户名:</label>
<input type="text" id="username" name="username">
<label for="password">密码:</label>
<input type="password" id="password" name="password">
<label for="gender">性别:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">男</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">女</label>
<label for="interests">兴趣:</label>
<input type="checkbox" id="reading" name="interests" value="reading">
<label for="reading">阅读</label>
<input type="checkbox" id="music" name="interests" value="music">
<label for="music">音乐</label>
<label for="city">城市:</label>
<select id="city" name="city">
<option value="beijing">北京</option>
<option value="shanghai">上海</option>
<option value="guangzhou">广州</option>
</select>
</form>
Represents a form that contains text input boxes, password input boxes, radio boxes, check boxes, and drop-down list boxes.
- What is the difference between block-level elements and inline elements in HTML? Please give an example.
Answer: Block-level elements are independent elements that occupy a single line and can set attributes such as width, height, margins, and padding. For example, <div>
and <p>
are block-level elements.
Inline elements are inline elements that do not occupy a single line, and can only set properties such as font, color, and background. For example, <span>
and <a>
are inline elements.
- Can elements in HTML be nested? Please give an example.
Answer: Yes. Elements in HTML can be nested within each other to form a tree structure. For example,
<div>
<p>这是一个段落</p>
<ul>
<li>列表项1</li>
<li>列表项2</li>
</ul>
</div>
Represents an element containing a paragraph and a list <div>
.
- What are meta tags in HTML? Please give an example.
Answer: The meta tag is used to provide the browser with the metadata of the webpage, including the description, keywords, and encoding of the webpage. For example,
<meta name="description" content="这是一个网页的描述">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta charset="UTF-8">
Represents a meta tag that contains web page description, keywords, and encoding information.
- What is the iframe tag in HTML? Please give an example.
Answer: The iframe tag is used to embed another web page within a web page, creating an inline frame. For example,
<iframe src="<https://www.baidu.com/>" width="100%" height="300"></iframe>
It means to embed the iframe tag of Baidu website in the webpage.
- What is the audio tag in HTML? Please give an example.
Answer: Audio tags are used to play audio in web pages, including <audio>
tags. For example,
<audio src="music.mp3" controls></audio>
Indicates that the audio named is played in the web page music.mp3
.
- What is the video tag in HTML? Please give an example.
Answer: The video tag is used to play video in web pages, including <video>
tags. For example,
<video src="video.mp4" width="320" height="240" controls></video>
Indicates that the video named is played in the web page video.mp4
.
- What is the canvas tag in HTML? Please give an example.
Answer: The canvas tag is used to draw graphics in web pages, including 2D and 3D graphics. For example,
<canvas id="myCanvas" width="200" height="100"></canvas>
It means to create a canvas with a width of 200 pixels and a height of 100 pixels in the web page.
- What is SVG in HTML? Please give an example.
Answer: SVG is Scalable Vector Graphics, which is used to create vector graphics in web pages. For example,
<svg width="100