Exploring CSS on my own and have the following HTML structure:
<style type="text/css">
#content { display: block; width: 250px; height: 50px; background-color: #330000; }
/* pink */
#one, #two, #three, #four { height: 25px; width: 25px; float: left; margin: 10px; }
/* yellow */
#five { height: 25px; width: 25px; float: right; margin: 10px; }
</style>
</head>
<body>
<div id="content">
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
<div id="four"></div>
<div id="five"></div>
</div>
The layout is functioning as expected, but I'm keen on minimizing duplicate code in the CSS. My aim is to consolidate common styles into one definition and specify unique background colors for each element.
Initially, I tried defining a shared style like this:
#content { height: 25px; width: 25px; float: left; margin: 10px }
Then assigning individual background colors:
#one { background-color: #FFCCCC; }
#five { background-color: #FFFF00; float: right; }
However, this approach didn't yield the desired outcome.
In essence, I'm looking to streamline redundant markup. What could I be overlooking?