Even if you never build a real-world compiler or kernel, understanding how they work can help you make better use of them when writing your own programs.
Like a toy compiler that implements a subset of a "real" programming language, a toy rendering engine could implement a small subset of HTML and CSS.
If you want to start contributing to major browser engines like Gecko or WebKit, you might want to work in C++ because it's the main language used in those engines, and using it will make it easier to compare your code to theirs.
In a learning exercise like this, you have to decide whether it's "cheating" to use someone else's code instead of writing your own from scratch.
Start a new program in the language of your choice, and write code to represent a tree of DOM text nodes and elements.