The easiest way to achieve this is to set min-height to the content above footer like this:
HTML:
<body>
<section>
This is content of the page
</section>
<footer>
Text of footer
</footer>
</body>
CSS:
section {
min-height: 100vh; /* minus the height of the footer */
}
jsfiddle link: https://jsfiddle.net/x55xh3v7/
But more "optimized" solution is the sticky footer techique which prevents the footer from unnecessary flowing out of the page.