Skip to content
Related Articles

Related Articles

How to add Flash content within a webpage in HTML?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 22 Mar, 2022

Flash is a vector animation software that was created with the intention of creating animations for web pages. Because vector graphics are so light, they are perfect for the web. There are different ways to insert a Flash file in HTML.

Method-1:  Using object and embed tag: The web standard for embedding content on a web page is the <object> tag, but the <embed> tag is a holdover from the days of the Netscape browser and is not a legitimate tag in web standards. Due to its great compatibility with many browsers, it is still widely used to embed Flash content today. Many major websites, such as YouTube, still provide embed codes in the above format.

Syntax: 

<object width="500" height="400">

    // You should replace somefilename with 
    // your own filepath or URL of your file
    <param name="movie" value="somefilename.swf">
    <embed src="somefilename.swf" 
        width="500" height="400">
    </embed>
</object>

Example:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>Adding Flash File</title>
</head>
  
<body>
    <h2>Welcome To GFG</h2>
    <object width="500" height="400">
        <param name="movie" value="file.swf">
        <embed src="file.swf" width="500" height="400">
        </embed>
    </object>
</body>
  
</html>

Nowadays Flash becomes outdated and is not supported by any browser. That’s why you see the output like this –

Output:

Method-2:  Using Comment tags: Far better, the standards-compliant solution is to include the comment tags that Internet Explorer browsers utilize. This approach is a hack, yet it adheres to the W3 standard and contributes to web standardization.

Syntax:

<![if !IE]>

// You should replace somefilename with your
// own filepath or URL of your file
<object type="application/x-shockwave-flash" 
    data="somefilename.swf" width="300" 
    height="200">
</object>
<![endif]>
<!--[if IE]>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase=
"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab
    #version=6,0,0,0"
    width="300" height="200">
<param name="movie" value="somefilename.swf" />
<![endif]-->

Example:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>Page Title</title>
</head>
  
<body>
    <h2>Welcome To GFG</h2>
    <![if !IE]>
    <object type="application/x-shockwave-flash" 
        data="file.swf" width="300" height="200">
    </object>
    <![endif]>
</body>
  
</html>

Output:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!