MyBlogHelp– A Blog for Digital Marketing, Affiliate Marketing, Organic Lead Generation.
  • Home
  • About
  • Contact
  • Privacy
  • Sitemap
  • BLOG
  • AFFILIATE MARKETING
    • LeadsArk
  • MORE
    • MAKE MONEY
      • ONLINE BUSINESS
      • ADSENSE
      • AFFILIATE MARKETING
    • BLOGGING
      • SEO
      • BlogSpot
      • WORPRESS
      • GOOGLE
      • COMPUTER TIPS
    • WEB DESIGN
      • HTML
      • CSS
      • BOOTSTRAP
      • JAVASCRIPT
      • JQUERY
    • WEB DESIGN
      • HTML
      • CSS
      • BOOTSTRAP
      • JAVASCRIPT
      • JQUERY
    • WEB DEVELOPMENT
      • PHP
      • WORDPRESS
  • DOWNLOADS
    • Blogger Template
    • Wordpress Theme
    • PDF

Sunday, December 9, 2018

How to use HTML script & noscript Tag?

 MyBlogHelp     December 09, 2018     html     No comments   


HTML-script-tag
script tag

Introduction of HTML <script> Tag

<script> tag of HTML is used to define client side script in web pages. For example, through the <script> tag you can add JavaScript in the HTML document. JavaScript is a client-side scripting language. With the help of this, you can generate dynamic content and validate forms etc.

Attributes of HTML <script> Tag

The attributes that are used in the script tag are given as below.

Src

By using this attribute you can define the URL of the external JavaScript and Its value will be in double quotes.

type

By using this attribute you can define the type of script. If you are using JavaScript, its value will be “text/JavaScript”.

async

The value of this attribute will be in the form of true and false. If you set this attribute true then the script is loaded asynchronously after all the elements of the HTML page are loaded. It is used to reduce page load time.

defer

The value of this attribute will also be in the form of true and false. When you set this attribute true, the script loads after HTML document is parsed.

Syntax of HTML <script> Tag

You can define the script tag like any normal HTML tag. Its simple syntax has been given as below.

       <script type = "text/javascript">
            // statements
       </script>

        You use src attribute to include an external JavaScript. Its simple syntax has been given below.

<script type = "text / javascript" src = "external-javascript-URL"> </ script>

As you can see in the syntax which is given above, when you include an external JavaScript in your page, you do not need to define in the script page.

 To set the script anonymously, you set the async attribute true. Its simple syntax is being given below.

<script type="text/javascript" src="external-javascript-URL" async="true"> </script>

To load a script after the page is parsed, you set the defer attribute true. Its simple syntax is being given below.

<script type="text/javascript" src ="external-javascript-URL" defer = "true"> </script>

How to use HTML script & noscript Tag?

You can use script tags in two ways in HTML documents.

Embedding Script

In this way, you define script only in the HTML document. By the way, you can define the <script> tag in HTML's <body> tag but most of the time it is defined in the <head> tag.

This is being explained by the example below.


         In the above example, the script is embedded in the page itself. This script generates the given output below.


html-script-tag

Linking Script

In this way, your script is stored on a server and you link it to your HTML document. For this, you use the src attribute of the <script> tag.

If you want to keep your script hidden and safe, then you can use this method for it. It is also called external javascript. This is being explained by the example below.


        In the above example, an external JavaScript is linked to the page. When you define external javascript, save it with a .js extension.


You can write the below code in “external-file.js” file.


You do not need to define <script> tag when defining an external JavaScript. The above script generates the given output below.

html-script-tag

HTML <noscript> Tag

Sometimes the script does not load in the page. It can happen for many reasons. For example, the user is using an old web browser that does not support script or the user has disabled the script itself.

Whatever the reason, in such situations, you can use <noscript> tag which is used to show the user appropriate message when the script is not loaded. You can use this tag anywhere in the head section or in the body section.

An example of this is being given below.


The above script generates the given output below.


html-noscript-tag




Previous:- How to use DOCTYPE declaration in HTML?

Next:- What is Meta Tag in HTML?















  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Thank you for reading this post. Please do not enter any spam link in the comment box.

Followers

Blog Archive

  • ►  2020 (4)
    • ►  October (1)
    • ►  September (1)
    • ►  August (2)
  • ►  2019 (52)
    • ►  December (1)
    • ►  November (2)
    • ►  October (1)
    • ►  August (1)
    • ►  July (1)
    • ►  May (11)
    • ►  April (10)
    • ►  March (6)
    • ►  February (3)
    • ►  January (16)
  • ▼  2018 (54)
    • ▼  December (27)
      • How to use html5 nav tag?
      • How to install Google Fonts on your Blogger Blog?
      • How to use section tag in html5?
      • How to use meter tag in html5?
      • How to use time tag in html5?
      • How to use header tag in HTML5?
      • How to use figure tag in html5?
      • How to use aside tag in html5?
      • How to use details Tag in HTML5?
      • How to use wbr tag in html5?
      • How to use article tag in HTML 5 ?
      • How to use menu tag in html?
      • How to use base tag in HTML?
      • How to use HTML hr and br Tag?
      • How to use HTML address tag?
      • How to use HTML Meta Tags?
      • How to use HTML script & noscript Tag?
      • How to use DOCTYPE declaration in HTML?
      • How to use Form Tag in HTML?
      • How to use Block and Inline Tags in HTML?
      • How to use Lists in HTML?
      • How to use Image Tag in HTML?
      • How to use Table Tag in HTML?
      • How to use anchor Tag in HTML?
      • How to Format & Style in HTML?
      • How to use Heading in HTML?
      • What is Attribute in HTML?
    • ►  November (5)
    • ►  May (5)
    • ►  April (4)
    • ►  February (3)
    • ►  January (10)
  • ►  2017 (17)
    • ►  December (9)
    • ►  November (8)

Popular Posts

  • How to use the main tag in html5?
  • How to use keygen tag in html5?
  • How to use html5 mark tag to highlight text?
  • How to start Online Business without money from home?
  • What is a search engine?

Contact Us

Name

Email *

Message *

About MyBlogHelp

Most of the posts, we share on this blog related to Affiliate Marketing, Organic Lead Generation, Digital Marketing, Social Media Marketing, Make Money Online, SEO, and web design.

Featured Post

LeadArk - Affiliate Marketing | Qualified Organic Lead Generation | LeadsArk Review

Copyright © MyBlogHelp– A Blog for Digital Marketing, Affiliate Marketing, Organic Lead Generation.
Design by Md. Abdussamad | MyBlogHelp.com