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,520 points
2,098 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,840 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, 2022 in HTML by Ashwini
• 5,430 points
459 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, 2022 in HTML by Tejashwini
• 3,820 points
457 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, 2022 in HTML by Tejashwini
• 3,820 points
633 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, 2022 in HTML by Tejashwini
• 3,820 points
317 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, 2022 in HTML by Tejashwini
• 3,820 points
701 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, 2022 in HTML by Ashwini
• 5,430 points
316 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,840 points
23,012 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,840 points
2,995 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,840 points
2,918 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,840 points
44,691 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP