Rules Hub

Coding Rules Library

← Back to all rules
frontend ruleStack: general
htmlclean-codebest-practiceslegacy

Omit default type attributes in HTML5

Do not specify `type="text/javascript"` for scripts or `type="text/css"` for styles, as they are implied defaults in HTML5.

PR: Feat/FCK-2096 - Login Modal UI fixes #712Created: Dec 7, 2025

Bad example

Old codejsx
1<script type="text/javascript" src="/analytics.js"></script>
2<style type="text/css">
3 body { margin: 0; }
4</style>

Explanation (EN)

The `type` attribute is explicitly set to the default values. This is legacy syntax that adds unnecessary verbosity to the markup without adding any value.

Objašnjenje (HR)

Atribut `type` eksplicitno je postavljen na zadane vrijednosti. Ovo je zastarjela sintaksa koja dodaje nepotrebnu opširnost oznakama bez ikakve stvarne koristi.

Good example

New codejsx
1<script src="/analytics.js"></script>
2<style>
3 body { margin: 0; }
4</style>

Explanation (EN)

Removing the `type` attribute relies on the standard HTML5 defaults (JavaScript for scripts, CSS for styles). The code is cleaner, shorter, and easier to read.

Objašnjenje (HR)

Uklanjanje atributa `type` oslanja se na standardne HTML5 zadane vrijednosti (JavaScript za skripte, CSS za stilove). Kod je čišći, kraći i lakši za čitanje.