Simple Animated GIF web page

How To Insert Animated GIF in HTML

Feel a regular image is too general? Want to make your site looks more cool? Let’s try to add some animated GIF images on your site.

To insert animated GIF in the web page. We use the html tag to achieve this. If you didn’t have an idea how to use the tag, we have another tutorial to teach you how to add an image on your website. At here, we use the same method, but we will place the image URL to the animated GIF URL.

To insert the GIF on your HTML web page, just add this link of code in your body element.

 

At the code above, I set the width as 100% to fit my blog post width. By using the tag to display the animated GIF on your HTML web page, the URL of the image should be correct.

Looks fun right? These GIF image are originated from giphy.com. There are many some others funny GIF on giphy.com.

If you are a completely beginning of HTML, but want to test it out with this code. You can simply run the code on the top-right side of the code snippet. If you want to create your own, HTML page from scratch. Check out How To Create an HTML Page. The code might looks like this.

     

Funny Animated GIF

Make it More fun and Attractive

There are a few ways to make the GIF image more attractive:

  1. Add a Caption: You can add a caption to the GIF image to make it more interesting and engaging. For example, you can add a funny caption that relates to the image.
  2. Add a Border: Adding a border to the image can help it stand out and make it more visually appealing. You can experiment with different border styles and colors to find one that complements the GIF.
  3. Adjust the Size: Depending on where you plan to use the GIF, you may want to adjust its size to fit the space. A smaller size may work better for social media, while a larger size may be better for a website.
  4. Change the Background: You can experiment with different background colors or patterns to make the GIF image stand out. A contrasting background can help the image pop.
Читайте также:  Python headers content disposition

Here’s an example of how you can modify the code to make the GIF image more attractive:

    /* add a border */ img < border: 2px solid #333; border-radius: 5px; >/* change the background */ body < background-color: #f5f5f5; >/* add a caption */ wh2 

Funny Animated GIF

When Your Monday Is a Prank.

Add Animation To The GIF Image

In this example, I’ve added a CSS animation that slides the caption in from the left when the page loads.

I’ve also added a CSS animation to the GIF image that rotates it continuously in a clockwise direction. You can adjust the animation duration, timing function, and other properties to customize the effect. Let me know if you have any other questions!

      

Funny Animated GIF

When Your Monday Is a Prank.

Источник

How to use an animated image in HTML page?

Animated images in HTML are an image on a web page that moves. It is in GIF format i.e. Graphics Interchange Format file.

We need to use the tag with the src attribute to add an animated image in HTML. The src attribute adds the URL of the image (file destination).

Also, we can set the height and width of the image using the height and width attribute.

Syntax

Example 1

Following is an example to show how to use an animated image in HTML page −

DOCTYPE html> html> head> meta charset="UTF-8"> meta name="description" content="meta tag in the web document"> meta name="keywords" content="HTML,CSS"> meta name="author" content="lokesh"> meta name="viewport" content="width=device-width, initial-scale=1.0"> head> body> p>Adding Animated Images to the web pagep> img src="https://tutorialspoint.com/images/html.gif"> body> html>

Example 2

You can try to run the following to work with the animated image in HTML −

DOCTYPE html> html> head> title>Animated Imagetitle> head> body> h1>Animated Imageh1> img src="https://media.giphy.com/media/3o6UBpHgaXFDNAuttm/giphy.gif"> body> html>

Example 3

We can change the height and the width of the animated image using the style sheet.

DOCTYPE html> html> head> meta charset="UTF-8"> meta name="description" content="meta tag in the web document"> meta name="keywords" content="HTML,CSS"> meta name="author" content="lokesh"> meta name="viewport" content="width=device-width, initial-scale=1.0"> head> body> p> dding Animated Images to the web pagep> img src="https://tutorialspoint.com/images/html.gif" height="200" width="200"> body> html>

Источник

How to Animate GIFs in HTML Document?

Many individuals use pictures, animated GIFs, and attractive colors to make their websites look more appealing. Thanks to HTML, that offers the “ ” element to embed images and GIFs to the web page. More specifically, a GIF is a collection of images or a soundless video that automatically plays without a play button. We can animate these gifs in CSS by utilizing the “animation” property.

This write-up will guide about:

How to Add GIFs in HTML Document?

Follow the steps to add a GIF to the HTML page:

  • Firstly, add a div element and assign it a class name “gif-style”.
  • To add a GIF, add an “ ” element with the “alt” and “src” attributes.
  • The “src” holds the URL of the GIF, and the “alt” attribute contains the alternate text, which displays when the image cannot load on the web page:

It can be observed that the GIF has been added to the HTML document successfully:

How to Animate GIFs in HTML?

The GIFs are already animated images, but users can improve them using the CSS properties. For this cause, take a look at the given properties.

Style “body” Element

The CSS “background-color” property is used to adjust the background color across the entire page.

Style “img” Element

.gif- style img {
width : 250px;
top: 50px;
position: absolute;
right: 0 ;
animation: animated-gif 15s infinite;
}

The “img” element of the “gif-style” div is set with these properties:

  • width” property determines the width of the GIF.
  • top” generates space for the element from the top.
  • position” sets the element’s position on the page. Its value “absolute” refers to the adjustment of GIF relative to the document’s body.
  • right” property is set to the value “0”, which means no space at the right of the image.
  • animation” is the shorthand property specifying the values for animation name, animation-duration, animation-iteration-count.

Applying @keyframe rules

@keyframes animated-gif {
0 % {
transform: translateX ( 300px ) ;
}
100 % {
transform: translateX ( -600px ) ;
}
}

The animation name “animated-gif” specified in the above code is utilized to set the @keyframe rules for the GIF:

  • At 0% of the animation, the GIF is relocated at “300px” on the x-axis.
  • At 100% of the animation, the GIF is adjusted at “-600px” on the x-axis.

The output has verified that the GIF has been successfully animated using CSS.

Conclusion

To embed GIFs in HTML documents, the “ ” element is utilized with the “src” attribute, which holds the URL of the GIF. Although these GIFs are already animated, we can add more animations using the CSS “animation” property. The “@keyframe” rules are then specified to determine the animation behavior. This post has demonstrated how to animate GIFs in HTML documents.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.

Источник

How to Insert a GIF into HTML — Like a Pro

How to Insert a GIF into HTML — Like a Pro

html-tuts.com

The use of GIFs in websites and email marketing has skyrocketed in the past seven or so years.

You probably might not believe it if you learned from this post that GIFs were created more than 30 years ago, with CompuServe being the first company to use a GIF in 1987.

Although it has taken a while for GIFs to find their footing, their success in social and professional settings is no denying.

This post will give you a comprehensive guide to inserting GIFs into HTML.

How to insert a GIF into HTML

To insert a GIF into HTML, you will use the standard image tag img src=” “/> used to insert images. However, instead of providing a path or link to the image in the source, you will need to add the path or link to your GIF.

Prepare the GIF You Want To Use

There are many online platforms where you can get free GIFs to use on your projects.

However, most of these GIFs might not meet your standards, and you will need to create one by yourself.

Some platforms you can use to create GIFs easily include Giphy, Adobe Photoshop, free animation software, and other image editors.

Always optimize your GIFs because a large file size will take time to load on the user end.

Note: If you are using HTML to insert GIFs in your marketing emails, only the first frame of the GIF is visible in Outlook (2007-2016) email clients.

Although most users might have updated their systems, there can’t lack that one person who still uses an older version.

Источник

Оцените статью