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 253641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:46:44+00:00 2026-05-11T21:46:44+00:00

I’ve just recently started learning HTML/CSS and I’ve been trying to teach myself sound

  • 0

I’ve just recently started learning HTML/CSS and I’ve been trying to teach myself sound web programming practices. I’m familiar with XML, so coding up webpages in XHTML was intuitive enough and it just seemed like a sound thing to do. However, I’ve been reading articles like this one
and now I’m ambivalent.

My concerns with coding in either HTML and XHTML stem from the following:

  1. img tags do not need to be closed in HTML, and that makes sense to me. But in XHTML, img tags require a close tag which seems kind of funky. I just think it’s weird to have a pair of open and close tags with nothing in between.
  2. p tags (as in paragraph) do not need to be closed in HTML, and that is funky to me. It makes sense to section off a paragraph between open and close tags as you would in XHTML.

These are the only basic examples I can come up with at the moment, but I’m hoping that they at least show how split I am between HTML and XHTML. So here’s my actual question: Is it okay to throw in XHTML code (when I feel that it appropriately clarifies something) when I’m coding up a webpage that should be in HTML (with an HTML DTD)? I’m sure the website would look the same, but if people were to look at my source, would they think I were a terribly unprofessional coder?

Also, I’ve been sort of blindly looking through tutorials and guides via Google on sound web programming practices and I was wondering if you folks had any advice/resources to share with me. I really want to make sure I’m learning how to do this the right way. I would really appreciate it.

Thanks for reading!

Edit: Wow, such fast responses; you guys are awesome! So I understand that web browsers are going to be pretty lenient when it comes to this sort of stuff. My problem is then a question of vanity and how other professionals feel about writing a sort of mix of XHTML and HTML. Is strictly compliant code the way to go? I honestly just don’t want to look like an idiot, haha.

  • 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-11T21:46:44+00:00Added an answer on May 11, 2026 at 9:46 pm

    img tags do not need to be closed in HTML,
    and that makes sense to me.

    No tag needs to be closed. All elements need to be closed.

    Most elements consist of a start tag, some content, and an end tag.

    Since an image element cannot have content, the end tag is not needed. In HTML, elements which cannot have content (“EMPTY elements”) have the end tags forbidden.

    But in XHTML, img tags require a close tag which seems kind of funky.

    XHTML is an XML application rather than an SGML application, and XML doesn’t have all the features that SGML does — including the ability to specify that an end tag is forbidden.

    I just think it’s weird to have a pair of open and close tags with nothing in between.

    XML introduces a new kind of tag — a self-closing tag (<foo />) which acts as a start and end tag combined.

    If you are writing HTML-Compatible XHTML (which you should be if you choose to use XHTML and want to support browsers which don’t support that language — such as Internet Explorer), then you should use that syntax. (I prefer to stick to HTML myself)

    p tags (as in paragraph) do not need to be closed in HTML, and that is funky to me.

    Many elements in HTML have optional end tags. This allows the end tag to be omitted when it can be implied.

    For example:

    <p>Hello, world
    <p>A second paragraph
    

    Since a p element cannot contain another p element, you can imply (with 100% reliability) that starting a new paragraph will close the previous one.

    That said, they are optional, not forbidden. You can write HTML 4.01 with explicit end tags for any element which isn’t intrinsically empty.

    Is it okay to throw in XHTML code
    (when I feel that it appropriately
    clarifies something) when I’m coding
    up a webpage that should be in HTML
    (with an HTML DTD)? I’m sure the
    website would look the same, but if
    people were to look at my source,
    would they think I were a terribly
    unprofessional coder?

    It would look unprofessional.

    That said, there are only three times when XHTML syntax is not conforming HTML syntax:

    Empty elements — such as <img> and <br> need to be explicitly closed in XHTML … but you said you didn’t like that syntax.

    Scripts and styles — you need to use character references or CDATA markers if you use certain characters in your embedded JS and CSS in XHTML, but these elements are marked as CDATA in the DTD for HTML, so this would be wrong there … but you shouldn’t use embedded scripts or styles anyway.

    Namespaces — but there is no time when using an XML namespace in the middle of an HTML document would come close to clarifying something.

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

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • 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 Maybe try this: tempform = $("<form method='post'></form>").attr('id','myForm'); tempform.attr("action", "abc.aspx"); $('body').append(tempform);… May 12, 2026 at 12:02 am
  • Editorial Team
    Editorial Team added an answer Assuming you've shutdown the database cleanly (ie not a SHUTDOWN… May 12, 2026 at 12:02 am
  • Editorial Team
    Editorial Team added an answer I wouldn't recommend Virtual PC because the performance is pretty… May 12, 2026 at 12:02 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

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

Top Members

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.