Hi @BhavaniKola,
If you're trying to do all of this directly in the Canvas editor, I think you're going to run into a lot of difficulties. Scripting is generally not allowed, and Canvas does limit what html elements and in-line styles you can use when editing HTML in the editor, see Canvas HTML Editor Allowlist - Instructure Community - 387066 for more details as to what is allowed.
Your best bet may be to host the content elsewhere where you then could include it as an iframe in Canvas. With this approach you may start to run into 3rd party content.cookie issues, especially as browsers focus a bit more on privacy.
I know some people also try putting html/javascript/css into the Canvas files area with somedegree of success, but I myself have never really considered this as a officially supported method, and I have noticed an uptick in posts here in the community about that style of content breaking for some users.
I may not have provided an exact answer here, but maybe something I said here will spark an idea on your end. Others may also chime in with their own advice around this.
-Chris