Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1100875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:57:02+00:00 2026-05-17T00:57:02+00:00

Image tag ( <img src= alt= /> ), line break tags ( <br />

  • 0

Image tag (<img src="" alt="" />), line break tags (<br />), or horizontal rule tags (<hr />) have the slashes at the end to indicate itself as self-closing tags. However, when these objects are created by javascript, and I look into the source, they don’t have the slashes, making them invalid by W3C standards.

How can I get over this problem?

(I use javascript Prototype library)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:57:03+00:00Added an answer on May 17, 2026 at 12:57 am

    How are you looking at ‘the source’? JavaScript-created elements don’t appear in ‘View Source’. Are you talking about innerHTML?

    If so then what you are getting is the web browser’s serialisation of the DOM nodes in the document. In a browser the HTML markup of a page is not the definitive store for document state. The document is stored as a load of Node objects; when these objects are serialised back to markup, that markup may not look much like the original HTML page markup that was parsed to get the document.

    So regardless of which of:

    <img src="x" alt="y"/>
    <img src="x" alt="y">
    <img  alt = "y"    src="x">
    img= document.createElement('img'); img.src= 'x'; img.alt= 'y';
    

    you use to create an HTMLImageElement node, when you serialise it using innerHTML the browser will typically generate the same HTML markup.

    If the browser is in native-XML mode (ie because the page was served as application/xhtml+html), then the innerHTML value certainly will contain self-closing syntax like<img/>. (You might also see other XML stuff like namespaces too, in some browsers.)

    However if, as is more likely today, you’re serving ‘HTML-compatible XHTML’ under the media type text/html, the browser isn’t actually using XHTML at all, so you’ll get old-school-HTML when you access innerHTML and you won’t see the self-closing /> form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 541k
  • Answers 541k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You forgot to apply the same reasoning to e2: function… May 17, 2026 at 2:55 am
  • Editorial Team
    Editorial Team added an answer The biggest difference (I think) is that live() attaches the… May 17, 2026 at 2:55 am
  • Editorial Team
    Editorial Team added an answer AFAIK, there is no proper core function for this in… May 17, 2026 at 2:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Assume I have the following string: Hellotoevryone<img height=115 width=150 alt= src=/Content/Edt/image/b4976875-8dfb-444c-8b32-cc b47b2d81e0.jpg />Iamsogladtoseeall. This
I've an image tag inside a div element. <div id = myDiv> <img alt
I have a list of images within a div tag with the id sIMG
I want to alter the class attribute of an image tag in PHP. I
If I have the path to an image stored in $thumbPath and I put
I'm writing some Javascript to resize the large image to fit into the user's
I have a slide show built with jQuery that pauses on hover. It has
Is it possible to change a html tag attribute value from an RSJ template?
HI all, I have a bunch of images that I need to wrap in
how I get the img code from a text? Now I get the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.