This is example code, not an actual project I'm working on:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
div.infoguide {
width: 800px;
border: 2px;
height: auto;
}
div.mynews1 {
float: left;
padding: 5px;
background-color:yellow;
font-size: 14px;
width: 80px;
height: 600px;
}
div.mynews2 {
margin: 10px;
background-color: blue;
font-size: 20px;
color: white;
width:400px;
height: 600px;
}
</style>
<title>Mypage</title>
</head>
<body>
<div class="infoguide">
This is the header
<div class="mynews1">
It works!
</div>
<div class="mynews2">
Good it worked
</div>
</div>
</div>
</body>
</html>
However, is it better practise in website design to leave spaces between the elements to avoid confusion when there's multiple <div> </div> elements, like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
div.infoguide {
width: 800px;
border: 2px;
height: auto;
}
div.mynews1 {
float: left;
padding: 5px;
background-color:yellow;
font-size: 14px;
width: 80px;
height: 600px;
}
div.mynews2 {
margin: 10px;
background-color: blue;
font-size: 20px;
color: white;
width:400px;
height: 600px;
}
</style>
<title>Mypage</title>
</head>
<body>
<div class="infoguide">
This is the header
<div class="mynews1">
It works!
</div>
<div class="mynews2">
Good it worked
</div>
</div>
</div>
</body>
</html>
My basic question; how should I go about making code cleaner and easier to understand, especially when designing website templates for my projects?