使用<div>标记在文档中添加一个部分。HTML <div>标记用于定义文档的一部分。使用div标签,您可以将HTML元素的大部分组合在一起,并使用CSS设置其格式。
您可以尝试以下代码创建一个部分-
<!DOCTYPE html> <html> <head> <title>HTML div Tag</title> <link rel = "stylesheet" href = "style2.css"> </head> <body> <div id = "contentinfo"> <p>Welcome to our website. We provide tutorials on various subjects.</p> </div> </body> </html>
以下是css文件 style2.css
#contentinfo p {
line-height: 20px;
margin: 30px;
padding-bottom: 20px;
text-align: justify;
width: 140px;
color: red;
}