For websites to have dynamic generated content, you need a script on a server (written with a server-side language) which will fetch informations from a database, and generate the page dynamically based on the requested informations.
User request -> Server get data -> Server send data back
One of the most common programming language used nowadays by beginners and freelancers is PHP, with the MySQL database, mainly because it's fast to learn, easy to implement, and it's available on almost any web server for free.
Latest technologies include AJAX, which uses asynchronous JavaScript requests to interrogate a server-side script, which will fetch the informations and send them back to your page. This for example will allow you to gather informations and update the page in real time, without the need to reload the document.
This is also the basis of modern social network websites and web applications.
With XHTML and CSS only you won't be able to create a dynamic website.
To explain further, you must understand that XHTML is a markup language. It does nothing by itself if not presenting a well formatted document.
CSS is a presentational document containing a set of rules to modify how your document will be displayed.
So you need one or more scripting languages to make your page reactive to the user inputs.
Lastly, it's worth mentioning that nowadays you could even be able to create a dynamic website concentrating only on the front-end, by utilizing CMS and scripts which will enable on your website the functionalities you need, with their own servers and server-side scripts.
I know there are many options available already, and probably it's possible to do what you need without knowing anything about server-side languages.