6 minute(s) read
Published on: Jun 03, 2021
Updated on: Dec 14, 2021
To be able to design a web application, you need to use a large number of programming languages, JS is the most popular among all the programming languages out there, and many programmers prefer to use it in order to achieve their desired goals, there are several commands in this language that need to be placed in the right place in order to be executed correctly, which we are going to discuss below, but before that we need to get a little familiar with the language itself.
It is one of the programming languages that is used to control the behavior of web pages along with other languages which are used for the basic structure of web pages, in order to turn the page into a page that users can interact with, this language can be used for different purposes, each of which is very important, and we need to focus more on learning them in programming, by mastering this language, it is possible to implement features that are very complex on the web.
Its commands in HTML code can be placed in 3 general places, which we are going to mention in the following.
1. Between the <head> ... </head> tag
2. Between the <body> ... </body> tag
3. In the external file with an extension ".js"
- Between the <head> ... </head> and <body> ... </body> tags:
Consider the following example, which is another example of it.
- In the external file with an extension ".js":
This commands can work in the following three ways when they are entered by different codes in HTML language.
When this happens, the HTML attribute will actually change, so in order to understand it more, you need to consider the following example.
Another thing that this commands can do on HTML elements is to hide them by displaying different elements.
Elements that are hidden can also be displayed.
In the above, we have mentioned the places where JS commands can be placed in general so that you can master the subject in a short while, but if you want to have more detailed information in this regard, we suggest you continue reading this article because there are other places that will be mentioned below.
- between <script> and </script> tags:
Here, the following example is given.
In order to understand more about this, you need to pay attention to the following example.
It may also be located as follows.
As we have mentioned at the beginning of the article, they may be located in external files, which an example will be given in the following, it should be noted that placing scripts in external files and then embedding them in HTML code causes these two types of code to be separate from each other, as a result, it makes easier to maintain each of them as well as reading them, in addition, saved JS files can speed up the loading of pages, which can be of great help to various programmers.
What is HTML?
It stands for Hyper Text Markup Language which is actually a language that is often used in the design of web pages, and in fact in this language all the code is converted to HTML and displayed by the browser, the version used these days is HTML5, so we will give you a brief description of it below.
What is HTML5?
HTML5 is the latest version of HTML that can provide many capabilities, including the ability to run images, audio and video files which can be effective in attracting different users to the site, this version is able to create very high graphics for websites, the advantage of this version compared to HTML4 is that by using it, you can ensure that the content that you intend to provide is presented correctly on different devices, and also with the help of this version, another possibility is provided that without the need for additional plugins, you can provide videos and other features to the customer and reach your main goal as a web owner, which causes gaining more customers, due to the fact that your website will be introduced to users' friends, so that you can achieve success with the help of HTML5 as soon as possible.