<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Center Div</title>
    <style>
        [class*='solution'] {
            border: 1px solid #000;
            width: 200px;
            height: 200px;
            box-sizing: border-box;
        }

        section {
            margin: 10px auto;
        }

        .child {
            width: 100px;
            height: 60px;
            background: #ff0;
            text-align: center;

        }

        .solution1 {
            line-height: 200px;
            text-align: center;

        }

        .solution1 .child {
            vertical-align: middle;
            margin: auto;
            display: inline-block;
            line-height: 1;
        }

        .solution2 {
            display: table;
        }

        .solution2>div {
            display: table-cell;
            vertical-align: middle;
            text-align: center;
        }

        .solution2 .child {
            display: inline-block;
        }

        .solution3 {
            position: relative;
        }

        .solution3 .child {
            position: absolute;
            top: 50%;
            left: 50%;
            margin: -30px 0 0 -50px;
        }

        .solution4 {
            position: relative;
        }

        .solution4 .child {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
        }

        .solution5 {
            padding: 60px 0 0 0;
        }

        .solution5 .child {
            margin: auto;
        }

        .solution6 #floater {
            float: left;
            height: 50%;
            width: 100%;
            margin-bottom: -30px;
        }

        .solution6 .child {
            clear: both;
            margin: auto;
        }

        .solution7 .child {
            transform: translate(-50%, -50%);
            margin: 50% 0 0 50%;
        }

        .solution8 {
            display: flex;
            justify-content: center;
        }

        .solution8 .child {
            align-self: center;
        }

        .solution9 {
            display: grid;
            justify-items: center;
            align-items: center;
        }

        .solution10 {
            position: relative;
        }

        .solution10 .child {
            position: absolute;
            top: calc(50% - 30px);
            left: calc(50% - 50px);
        }

        .solution11 {
            position: relative;
        }

        .solution11 .child {
            position: absolute;
            top: 50%;
            left: 50%;
        }
    </style>
</head>

<body>

    <table>
        <tr>
            <td>Fixed Dimensions</td>
            <td>variable Dimensions</td>
        </tr>
        <tr>
            <td>
                <section class="solution1">
                    <div class="child">1 - Line height with fixed dimensions</div>
                </section>
            </td>
            <td>
                <section class="solution2">
                    <div>
                        <div class="child">2 - Table Cell with Unknown height & Width</div>
                    </div>
                </section>
            </td>
        </tr>
        <tr>
            <td>
                <section class="solution3">
                    <div class="child">3 - Position Absolute</div>
                </section>
            </td>
            <td>
                <section class="solution4">
                    <div class="child">4 - Position Absolute with stretching</div>
                </section>
            </td>
        </tr>
        <tr>
            <td>
                <section class="solution5">
                    <div class="child">5 - Using Padding</div>
                </section>
            </td>
            <td>
                <section class="solution7">
                    <div class="child">7 - Translate x & y</div>
                </section>
            </td>
        </tr>
        <tr>
            <td>
                <section class="solution6">
                    <div id="floater"></div>
                    <div class="child">6 - Float with fixed Height</div>
                </section>
            </td>
            <td>
                <section class="solution8">
                    <div class="child">8 - Using Flex</div>
                </section>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <section class="solution9">
                    <div class="child">9 - Using grid</div>
                </section>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <section class="solution10">
                    <div class="child">10 - Using calc</div>
                </section>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <section class="solution11">
                    <div class="child" id="jsChild">11 - Using javascript</div>
                </section>
            </td>
        </tr>
    </table>

















    <script>
        var jsChild = document.getElementById("jsChild");
        jsChild.setAttribute("style", "margin-top: -" + jsChild.offsetHeight / 2 + "px; margin-left: -" + jsChild.offsetWidth / 2 + "px;");
    </script>
</body>

</html>
// Code goes here

/* Styles go here */