Is it possible to use the canvas tag in HTML 4.01?

Asked 2 years ago, Updated 2 years ago, 98 views

Is it possible to use the canvas tag in HTML 4.01?

I was able to draw a graph using Chart.js in the following description, but I think the canvas tag can be used from HTML5.

If anyone knows, could you tell me?
Thank you for your cooperation.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <metacharset="utf-8">
 <title> Graph </title> 
</head>
<body>
  <h1>Test Graph</h1>
  <canvasid="myBarChart">/canvas>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.bundle.js"></script>

  <script>
  varctx = document.getElementById("myBarChart");
  var myBarChart = new Chart (ctx, {
    type: 'bar',
    data: {
      labels: ['August 1', 'August 2', 'August 3', 'August 4', 'August 5', 'August 6', 'August 7',
      datasets:
        {
          label: 'Number of people',
          data: [10, 20, 30, 40, 55, 65, 70],
          backgroundColor: "rgba (219, 39, 91, 0.5)"
        }
      ]
    },
    options: {
      title: {
        display —true,
        text: 'Number of people'
      },
      scale: {
        yAxes: [{
          ticks: {
            SuggestedMax: 100,
            SuggestedMin: 0,
            stepSize:10,
            callback:function(value, index, values){
              return value + 'people'
            }
          }
        }]
      },
    }
  });
  </script>
</body>
</html>

html html5-canvas

2022-09-30 16:32

1 Answers

As mentioned in the questionnaire, HTML 4.01 does not support canvas tags.Some browsers may interpret and display them independently, but they are out of specification.

HTML5 was first recommended in 2014.Today, if HTML 4.01 can be avoided, it is better to avoid it.If you are particular about HTML 4.01, you will have to draw without using the canvas tag.Of course, you can't use Chart.js, so you'll have to use another method.


2022-09-30 16:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.