/

HTML / CSS / JavaScript Tutorial

HTML Element: <head>

[this page | pdf | back links]

The HTML <head> element provides information about the document. The <head> element can contain the following sorts of elements (it is always supposed to include a <title> element, but HTML that does not do so may not be rejected by browsers):

 

-        <base>

-        <link>

-        <meta>

-        <noscript>

-        <script>

-        <style>

-        <title>

 

The attributes it can take are HTML global attributes and HTML event attributes.

 

It used to support the profile attribute, but this is no longer supported in HTML 5.

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods. The default style applicable to this element is shown here.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<link rel="stylesheet" type="text/css" href="Content/ExampleStyleEMBordered.css">
<!-- the above style sheet contains the following style: em.class1 {border: thin solid blue;} --> 
</head>
<body>
Created using HTML:<br>
<em class="class1">bordered in blue, using a linked style sheet in head element accessed via HTML</em>

<br><br>Created using JavaScript:<br>
<em class="class2">bordered in red, using a linked style sheet inserted via JavaScript into head element</em>

<script>
var x = document.createElement("LINK");
x.setAttribute("rel","stylesheet");
x.setAttribute("type","text/css");
x.setAttribute("href","Content/ExampleStyleEMBordered2.css");
document.getElementsByTagName("HEAD")[0].appendChild(x);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile