That depends if you have a retail or OEM license.
If you have an OEM license, legally that license has to remain with the machine (or hardware) it was originally sold with. It doesn't matter what you "can" do, because that's the facist way that Microsoft operates their licensing.
If you have a retail license, the rules are a bit different.
Overall however, Microsoft tries to discourage people from ever transferring ownership of a Windows license.
However, what are they gonna do? So go for it.