Artikel HTML5 CSS und JavaScript einbinden - Meta-Viewport-Tag

Embed HTML5 CSS and JavaScript – Meta Viewport tag

21. January 2020

This small overview gives a quick access to the most important HTML5 tags to include resources (CSS and JavaScript) and to set the viewport handling correctly for responsive projects.

 

 

Set Viewport

Markup
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
...
</head>

Although viewport is not yet standardized in any way as a value for the name attribute, it is supported by all relevant browsers (on mobile devices).

The tag causes browsers to display the page in the size of the device pixels and not to try to scale down a large page. Peter Paul Koch explains the connections excellently.

In some projects it is necessary to use the other specifications like user-scalable, minimum-scale and maximum-scale.

 

 

Include CSS

Markup
<head>
<link href="styles.css" rel="stylesheet">
...
</head>

The specification of the type attribute (type=”text/css”) is not necessary, since it is only a hint for the browser which MIME type to expect for the external resource.

It is ultimately the resource itself that determines which content type it returns. The browser then decides whether it is compatible with the link type stylesheet and is taken into account in rendering.

 

 

Include JavaScript

Markup
  ...
<script src="scripts.js"></script>
</body>

The type attribute on the script tag behaves similar to CSS. It is an indication of the MIME type of the linked script file for the user agent. If omitted, the browser assumes type=”text/javascript” by default.

The end tag must not be omitted for script.

SIE KÖNNEN SICH BEI UNS BEDANKEN!

Sofern Ihnen der Artikel geholfen hat, können Sie sich mit wenig Aufwand revanchieren!

 

Bitte hinterlassen Sie uns eine positive Bewertung.

 

Falls Sie Fehler entdecken oder ein Artikel unvollständig ist, freuen wir uns über einen Kommentar.

Bewertung erstellen

Comments

Tell us what you think! Reply now

Your email address will not be published. Required fields are marked *