I use the SharePoint Online Modern Experience.
This is my HTML file called test.html. It is both on my computer and SharePoint online:
As mentioned above it runs and displays correctly on my computer like so:
I created a SharePoint page and used the Embed web part to reference this HTML file using iFrame. My iFrame code is like so:
<iframe id="inlineFrameExample" title="Inline Frame Example" width="300" height="200" src="path to above HTML file"> </iframe>