<style> .container{ position: relative; border: 1px solid #000011; top: 100px; height: 500px; width: 500px; } #cm{ position: absolute; border: 1px solid red; margin: auto auto; } .hc{ width: 200px; left: 0; right: 0; } .vc{ height: 40px; top: 0; bottom: 0; } </style> </head> <body> <div class="container"> <p id="cm" class="hc vc"></p> </div>