SGML (Standard generalized markup language) is a standard which tells how to specify document markup. It’s only a Meta language which describes how a document markup should be. HTML is a markup language which is described using SGML.
So by SGML they created DTD which the HTML refers and needs to adhere to the same. So you will always find “DOCTYPE” attribute at the top of HTML page which defines which DTD is used for parsing purpose.
Now parsing SGML was a pain so they created XML to make things better. XML uses SGML. For example in SGML you have to start and end tags but in XML you can have closing tags which close automatically (“</customer>”).
XHTML was created from XML which was used in HTML 4.0. So for example in SGML derived HTML “</br>” is not valid but in XHTML it’s valid. You can refer XML DTD as shown in the below code snippet.
In short SGML is the parent of every one. Older HTML utilizes SGML and HTML 4.0 uses XHTML which derived from XML.