I am learning HTML5 and CSS 3 (newbie). When I went through an example in a book, I faced a rendering problem.
What I am trying to do: Create a Faux Column.
Working sample:
<!doctype html>
<html>
    <head>
        <title>Faux Columns</title>
        <style>
            .container{
                background: black;
                color: #fff;
            }
            .container::after{
                content: ' ';
                clear: both;
                display: block;
            }
            .col{
                float: left;
                width: 50%;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <aside class="col">
                Aside
            </aside>
            <div class="col main">
                Main Content Area
            </div>
        </div>
    </body>
</html>Run the script, and you can see the two columns.
Now run this script,
<!doctype html>
<html>
    <head>
        <title>Faux Columns</title>
        <style>
            .container{
                background: black;
                color: #fff;
            }
            .col{
                float: left;
                width: 50%;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <aside class="col">
                Aside
            </aside>
            <div class="col main">
                Main Content Area
            </div>
        </div>
    </body>
</html>Why is the above not rendered?
- What am I doing wrong?
- Also, in the working sample what is ::after?
- In the working sample CSS content: ' '; why this is set?
- What does that working sample CSS actually do?
As per some comments, I just changed the color in my parent container.
<!doctype html>
<html>
    <head>
        <title>Faux Columns</title>
        <style>
            .container{
                background: black;
                color: red;
            }
            .col{
                float: left;
                width: 50%;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <aside class="col">
                Aside
            </aside>
            <div class="col main">
                Main Content Area
            </div>
        </div>
    </body>
</html>Now I can see the two columns. But the parent's background colour black is not set.
 
     
     
     
     
     
     
     
     
    