Why don t self-closing script elements work

0 votes

What is the reason browsers do not correctly recognize:

<script src="foobar.js" /> <!-- self-closing script element -->

Only this is recognized:

<script src="foobar.js"></script>

Does this break the concept of XHTML support?

Apr 23, 2020 in HTML by kartik
• 37,500 points
513 views

1 answer to this question.

0 votes

Hello @kartik,

That's because SCRIPT TAG is not a VOID ELEMENT.

In an HTML Document - VOID ELEMENTS do not need a "closing tag" at all!

In xhtml, everything is Generic, therefore they all need termination e.g. a "closing tag"; Including br, a simple line-break, as <br></br> or its shorthand <br />.

However, a Script Element is never a void or a parametric Element, because script tag before anything else, is a Browser Instruction, not a Data Description declaration.

Hope this works!!

Thank You!!

answered Apr 23, 2020 by Niroj
• 82,740 points

Related Questions In HTML

0 votes
0 answers

Are (non-void) self-closing tags valid in HTML5?

On non-void elements, self-closing tags (those that ...READ MORE

Jul 26 in HTML by Ashwini
• 1,160 points
6 views
0 votes
0 answers

Why doesn't my div inside a span work properly?

I'm writing the following HTML markup: <span> Some Text ...READ MORE

Jul 29 in HTML by Tejashwini
• 1,660 points
6 views
0 votes
0 answers

How to use HTML script tags to code while they have a source link?

I have seen that  <script src="..."></script> does not allow ...READ MORE

Jul 4 in HTML by Tejashwini
• 1,660 points
5 views
0 votes
0 answers

Why does HTML5 recommend putting the code element inside pre?

The HTML5 documentation recommends putting the code ...READ MORE

Jul 4 in HTML by Tejashwini
• 1,660 points
11 views
0 votes
0 answers

Why image in HTML is showing as broken image

I have the following HTML code and ...READ MORE

Jul 4 in HTML by Tejashwini
• 1,660 points
14 views
0 votes
0 answers

What is the difference between HTML div and span elements?

Please provide some straightforward examples of how ...READ MORE

Jul 21 in HTML by Ashwini
• 1,160 points
5 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,740 points
14,571 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,740 points
1,646 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,740 points
1,360 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,740 points
19,697 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP