How to Add an HTML Tag to the HEAD of an HTML Doc in JavaScript

Cloudmersive
1 min readJul 9, 2021

--

The basic design of an HTML document requires that an HTML tag be present at the beginning and end of the document. To avoid inadvertently forgetting the HTML tag, we will be demonstrating how to add an HTML tag to the HEAD of an HTML document by running a document conversion API in JavaScript.

First, we will run this command to install jQuery:

bower install jquery

Following the installation, we are ready to call the function as shown in the below example code:

var settings = {
"url": "https://api.cloudmersive.com/convert/edit/html/head/append/tag",
"method": "POST",
"timeout": 0,
"headers": {
"inputFileUrl": "<string>",
"htmlTag": "<string>",
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": {
"inputFile": "<binary>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});

By the end of this quick operation, the HTML tag will be appended to the HEAD of your document, and your process will be complete!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet