Does it make sense to declare a doctype for an HTML fragment?

115 views Asked by At

If I have an HTML5 component/WebComponent that has a component.html file that defines a <template>, does it make sense to have a <!DOCTYPE html> declaration in component.html? That is, which of the following is best practice?

<template>
    <!-- some html content -->
</template>

Or

<!DOCTYPE html>
<template>
    <!-- some html content -->
</template>
1

There are 1 answers

0
Supersharp On BEST ANSWER

Both will be parsed and processed the same way in all modern browsers that support the template element.

One is a few octets lighter!

So it depends if you prefer speed over strict standards compliance

Following the KISS principle: The less code I write (and read), the better I feel ;-)