为什么标题和div标签中的内容不能融合在一起呢?


.title {
    font-size: 20px;
    font-weight: bold;
    text-indent: 1em;
    line-height: 35px;
    color: aqua;
    background: red;
}

ul{
    background: darkgrey;
}
ul li {
    height: 20px;
    list-style: none;
    text-indent: 1em;
}

a {
    text-decoration: none;
}

a:hover {
    color: coral;
    text-decoration: underline;
}

#nav {
    background: aquamarine;
    width: 400px
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>列表样式</title>
    <link rel="stylesheet" href="css/style02.css" type="text/css">
</head>
<body>
<h2 class="title"> 全部商品分类</h2>
<div id="nav">
    <ul>
        <li><a href="#"> 图书</a> &nbsp; &nbsp;<a href="#">音像</a> &nbsp;&nbsp;</li>
        <li><a href="#"> 家用电器</a> &nbsp; &nbsp;<a href="#">手机</a> &nbsp;&nbsp;</li>
        <li><a href="#"> 办公</a> &nbsp; &nbsp;<a href="#">电脑</a> &nbsp;&nbsp;</li>
        <li><a href="#"> 彩票</a> &nbsp; &nbsp;<a href="#">旅行</a> &nbsp;&nbsp;</li>
    </ul>
</div>
</body>
</html>

结果就是这样

img

但是我想那块红色跟灰色区域是连在一起的,要怎么改

标题标签默认会有个上下边距的,设置为零就好了


*{
margin:0;
padding:0;
}