Home > Web Front-end > HTML Tutorial > What types of graphics does HTML5 support?

What types of graphics does HTML5 support?

PHPz
Release: 2023-08-27 11:01:16
forward
1009 people have browsed it

What types of graphics does HTML5 support?

Graphics are visual representations used to represent any idea or imagination to enhance the user's overall experience with the website. Graphics help convey complex information to users in a simple and understandable way. Some ways to represent information graphically are through photos, art, diagrams, flow charts, etc.

Graphics in HTML are used to enhance the appearance of a web page or website and make user interaction easy. Graphics in HTML serve different purposes, and we have different techniques for this. We will discuss some of them below.

SVG

SVG stands for Scalable Vector Graphics. It's like HTML for graphics. SVG files are always saved with the .svg extension. The tag is a container tag because it has opening and closing tags, and in order to work, it must be added inside the element. It produces high-quality graphics, animations, and images that are reusable, easy to understand, and easy to import. They can be easily modified by editing the markup language or editing using a style sheet such as CSS.

SVG has many built-in features such as gradients, opacity, filters, and more, all of which provide scalable, smooth, and reusable graphics for web pages.

Example: Using SVG as an image file

<!DOCTYPE html>
<html lang="en">
<head>
   <title>SVG</title>
</head>
<body>
   <h1>Below is an example of an svg used as an image.</h1>
   <img src="https://www.tutorialspoint.com/images/physics-tutorials_icon.svg" alt="SVG">
</body>
</html>
Copy after login

Example 2: Using SVG as a background image

<!DOCTYPE html>
<html lang="en">
<head>
   <title>SVG</title>
   <style>
      body{
         background: url("https://www.tutorialspoint.com/images/physics-tutorials_icon.svg") no-repeat;
      }
   </style>
</head>
<body>
   <p>This is Using SVG as background image</p>
</body>
</html>
Copy after login

Example 3: Using SVG as-is

<!DOCTYPE html>
<html lang="en">
<head>
   <title>Document</title>
</head>
<body>
   <svg
      xmlns="http://www.w3.org/2000/svg"
      width="375.00078"
      height="728.17084"
      viewBox="0 0 375.00078 728.17084"
      xmlns:xlink="http://www.w3.org/1999/xlink"
   >
   <path
      d="M2.79045,484.29492c-.55273,0-1-.44727-1-1V201.5c0-70.91211,57.69043-128.60254,128.60254-128.60254h217.13771c.55273,0,1,.44727,1,1s-.44727,28-1,28l217.1377-27C60.58439,74.89746,3.79045,131.69141,3.79045,201.5V483.29492c0,.55273-.44727,1-1,1Z"  fill="#3f3d56"
   />
   <path
      d="M348.29044,0c.55273,0,1,.44727,1,1V282.79492c0,70.91211-57.69043,128.60254-128.60254,128.60254H3.55021c-.55273,0-1-.44727-1-1s.44727-1,1-1H220.68792c69.80861,0,126.60255-56.79395,126.60255-126.60254V1c0-.55273,.44727-1,1-1h-.00003Z"  fill="#3f3d56"/>
</body>
</html>
Copy after login

CSS

CSS stands for Cascading Style Sheets. It is a language used to describe the presentation of a web page and its components such as color, layout, and font information. CSS files are saved with the .css extension.

Mainly used to modify HTML and SVG elements through CSS attributes. HTML elements have several built-in CSS properties, such as fonts, we have font-size, fontwidth, font-weight. Likewise, for other elements we have other properties. All of these properties, when applied to HTML and SVG elements, produce web pages that are scalable, simple, and easy for users to understand.

Example

<!DOCTYPE html>
<html lang="en">
<head>
   <title>CSS</title>
   <link rel="stylesheet" href="style.css">
  <style>
      body{
         background-image: url("image.jpg");
         background-color:aqua;
         background-repeat: repeat;
         background-position: 0%;
      }
      h1{
         color:black;
         border: 2px solid black;
         font-size: 50px;
      }
      p{
         color:black;
         border:2px solid black;
         font-size: 50px;
      }
   </style>
</head>
<body>
   <h1>This is an exmaple of using CSS with HTML.</h1>
   <p>CSS helps in making the content and images of the webpage looks more simpler and presentable.</p>
</body>
</html>
Copy after login

Canvas API

The Canvas API is a client-side scripting technology that allows rich creation or modification of raster images. The Canvas API uses a vector-based approach to creating shapes and other graphical effects, and since it doesn't have a DOM (Document Object Model), it can perform faster.

Canvas API is used to create graphics using javascript and elements. The element has two attributes, width and height, both of which are optional. But if we use these properties and don't set their values, then by default the width will be set to 300px and the height to 150px. Canvas API is widely used by developers to develop high-end games and full-featured applications.

Example

<!DOCTYPE html>
<html lang="en">
<head>
   <title>CANVAS API</title>
</head>
<body>
   <h1>This is an example of CANVAS API in HTML</h1>>
   <canvas id="canvas" width="300" height="150" style="border:2px solid black;"></canvas>
   <script>
      var c = document.getElementById("canvas");
      var ctx = c.getContext("2d");
      ctx.beginPath();
      ctx.arc(100,55,45,0,2*Math.PI);
      ctx.stroke();
   </script>
</body>
</html>
Copy after login

PNG - PNG stands for Portable Network Graphics. It is a static file format used for portable, well-compressed storage and exchange of raster images. PNG files are always saved with the .png extension.

PNG files are colorful, with indexed color, grayscale, and have alpha channel transparency. It can be used with HTML, CSS and SVG. PNG files are primarily designed for the web because of their faster streaming and progressive rendering capabilities. Due to these features, they are highly supported in web browsers, graphic creation tools, and imaging toolkits.

In the above lines, we discussed some ways to use graphics in html, but we are not limited to these methods, html and css provide many other ways to use graphics. Given the flexibility offered by html, it is also possible to use moving graphics through animation, automatically change graphics using carasoul, and work with videos.

in conclusion

In conclusion, data analysis can be a powerful tool for emergency management. It allows organizations to collect and analyze data in real-time, identify trends and respond quickly to disasters. Data analytics can also help predict future events, develop more accurate emergency response plans, and improve overall preparedness. By harnessing the power of data analytics for emergency management, organizations can better protect their communities from disaster-related threats.

The above is the detailed content of What types of graphics does HTML5 support?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template