Convert a CSS selector to HTML
PHP, 125 119 bytes
&lt;?=preg_replace(['/#([\w-]+)/','/\.([^[]+)/','/[.[\]]/','/(\S+).*/'],[' id=&quot;$1&quot;',' class=&quot;$1&quot;',' ','&lt;$1&gt;&lt;/$1&gt;'],$argn);

Just regex replacements.

Saved 6 bytes thanks to Christoph.