If you include raw latex as you did inside the Rmd document, it will only be useful to create pdf. This raw latex code won't be able to generate HTML code for an HTML output.That is why currently you can't render html file. PDF only.
However, knitr includes a tikz engine that you could use no matter the output format. Here is an example to produce HTML
---
title: "Hello World"
author: "Me"
date: "February 24, 2020"
output: html_document
---
## TikZ picture
Here is a TikZ picture
```{tikz, fig.cap = "Funky tikz", fig.ext = 'png'}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\definecolor{zzffzz}{rgb}{0.6,1,0.6}
\definecolor{ffcctt}{rgb}{1,0.8,0.2}
\definecolor{yqyqdz}{rgb}{0.5019607843137255,0.5019607843137255,0.8509803921568627}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\clip(-4.505289256198347,-6.316528925619829) rectangle (21.02198347107439,13.083471074380155);
\draw [line width=2pt,pattern color=yqyqdz,fill=yqyqdz,fill opacity=0.25] (2,0) circle (3cm);
\draw [line width=2pt,pattern color=ffcctt,fill=ffcctt,fill opacity=0.25] (6,0) circle (3cm);
\draw [line width=2pt,pattern color=zzffzz,fill=zzffzz,fill opacity=0.25] (4,3.46415) circle (3cm);
\end{tikzpicture}
```
See also knitr example
This knitr engine seems the way to go if you want to reach multiple format using tikz.
hope it helps