Using languages like PHP you can instruct the web page to query a database in advance of rendering the html. You can write the page's script to fetch variables that are retrieved from a database and inserted into the HTML.
Php and others are "server-side" applications. The processing gets handled at the server. Your browser only sees HTML.
If you click on "view source" there won't be direct evidence that much of the information on the page came from a database.
It's all very cool. And there are tons of resources on this.
A very basic book on this is: Build Your Own Database Driven Website Using PHP and MySQL by Kevin Yank.
Good luck.