I want to add a space between two columns. I have tried adding margin but that moves the second column under the first. Any example I have seen are for bootstrap.
Here is what I am trying to replicate

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
#heading {
border: 1px double black;
}
.column {
float: left;
width: 50%;
border: 1px solid black;
}
.row {
padding: 5px;
border: 1px solid black;
}
.row:after {
content: "";
display: table;
clear: both;
padding: 5px;
}
h2, h3 {
text-align: center;
}
</style>
</head>
<body>
<h2 id="heading">Two Equal Columns</h2>
<div class="row">
<div class="column">
<iframe width="100%" src="https://www.youtube.com/embed/bjmYkPkjnVo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<h3>Ingredients</h3>
<ol>
<li>1 pound dry spaghetti</li>
<li>salt and freshly ground black pepper to taste</li>
<li>6 cloves garlic, sliced thin</li>
<li>1/2 cup olive oil (note: I prefer a regular olive oil for this recipe, as opposed to a strongly flavored extra virgin olive oil)</li>
<li>1/4 teaspoon red pepper flakes, or to taste</li>
<li>1/4 cup chopped Italian parsley</li>
<li>1 cup finely grated Parmesan cheese (highly recommend Parmigiano-Reggiano)</li>
<li>1 tablespoon of butter</li>
</ol>
</div>
<div class="column">
<iframe width="100%" src="https://www.youtube.com/embed/sAhUTzTJNaE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<h3>Ingredients</h3>
<ol>
<li>500g of Pasta (cooked as per packet directions)</li>
<li>30g of Butter</li>
<li>4 Cloves of Minced Garlic (about 3-4 teaspoons)</li>
<li>1 1/2 Cups of Cream (about 400ml)</li>
<li>Salt and Pepper</li>
<li>1/2 Cup of Freshly Grated Parmesan Cheese</li>
<li>2 Teaspoons of Freshly Chopped Parsley (plus extra to garnish)</li>
</ol>
</div>
</div>
</body>
</html>
The problem is that both of your columns occupy 50% width. You'll need to shrink this, allowing you to make use of the newly-created margin.
In the following, I've changed this width to 45%, and then added margin-right of 10% to the first column (with the selector .column:first-of-type).
Note that the columns with the additional margin still occupy the full width, as the two columns now total 90%, leaving the 10% for the margin. If you want to adjust this, simply ensure that the margin is equal to 100% minus the total width of the columns.
* {
box-sizing: border-box;
}
#heading {
border: 1px double black;
}
.column {
float: left;
width: 45%;
border: 1px solid black;
}
.column:first-of-type {
margin-right: 10%;
}
.row {
padding: 5px;
border: 1px solid black;
}
.row:after {
content: "";
display: table;
clear: both;
padding: 5px;
}
h2,
h3 {
text-align: center;
}
<body>
<h2 id="heading">Two Equal Columns</h2>
<div class="row">
<div class="column">
<iframe width="100%" src="https://www.youtube.com/embed/bjmYkPkjnVo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<h3>Ingredients</h3>
<ol>
<li>1 pound dry spaghetti</li>
<li>salt and freshly ground black pepper to taste</li>
<li>6 cloves garlic, sliced thin</li>
<li>1/2 cup olive oil (note: I prefer a regular olive oil for this recipe, as opposed to a strongly flavored extra virgin olive oil)</li>
<li>1/4 teaspoon red pepper flakes, or to taste</li>
<li>1/4 cup chopped Italian parsley</li>
<li>1 cup finely grated Parmesan cheese (highly recommend Parmigiano-Reggiano)</li>
<li>1 tablespoon of butter</li>
</ol>
</div>
<div class="column">
<iframe width="100%" src="https://www.youtube.com/embed/sAhUTzTJNaE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<h3>Ingredients</h3>
<ol>
<li>500g of Pasta (cooked as per packet directions)</li>
<li>30g of Butter</li>
<li>4 Cloves of Minced Garlic (about 3-4 teaspoons)</li>
<li>1 1/2 Cups of Cream (about 400ml)</li>
<li>Salt and Pepper</li>
<li>1/2 Cup of Freshly Grated Parmesan Cheese</li>
<li>2 Teaspoons of Freshly Chopped Parsley (plus extra to garnish)</li>
</ol>
</div>
</div>
</body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With