HTML5和CSS图标主要涉及到网页设计和前端开发领域。以下是对这个问题的全面解答:
:before和:after伪元素结合字体或SVG来创建图标。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Icon Example</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
<style>
.icon {
font-size: 24px;
color: #333;
}
</style>
</head>
<body>
<i class="fas fa-home icon"></i> Home
</body>
</html>请注意,以上示例代码使用了FontAwesome字体图标库,您可以根据需要替换为其他图标库或自定义样式。