html全局样式基础代码
导读:在网页设计中,有时需要为整个网页设置全局样式,统一设置一些基础的样式,这时就需要使用HTML的全局样式基础代码。<!DOCTYPE html><html> <head> <title>...
在网页设计中,有时需要为整个网页设置全局样式,统一设置一些基础的样式,这时就需要使用HTML的全局样式基础代码。
!DOCTYPE html>
html>
head>
title>
网页标题/title>
style>
* {
margin: 0;
padding: 0;
}
body {
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
background-color: #f1f1f1;
}
a {
color: #333;
text-decoration: none;
}
h1, h2, h3 {
font-weight: bold;
margin-bottom: 10px;
}
p {
margin-bottom: 20px;
}
img {
max-width: 100%;
height: auto;
}
ul {
list-style: none;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
/style>
/head>
body>
div class="container">
h1>
网页标题/h1>
p>
网页内容....../p>
ul>
li>
列表1/li>
li>
列表2/li>
/ul>
img src="image.jpg">
/div>
/body>
/html>
以上代码为一个基础的HTML全局样式设置,其中使用了通配符*和标签选择器来对全局元素进行设置(如重置外边距和内边距),也使用了类选择器.container来对特定元素进行设置(如设置为最大宽度为1200px的居中容器)。
通过设置HTML的全局样式,可以方便地对整个网页进行统一的样式调整,提高设计效率。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: html全局样式基础代码
本文地址: https://pptw.com/jishu/530796.html
