We help IT Professionals succeed at work.
Get Started

HELP - Self Closing tags in XHTML strict causing page to render incorrectly in all browsers.

Last Modified: 2013-11-19
Below is a snippet of code that I believe SHOULD render differently than it does.

Step one: Create an image that is a 16 x 16 .PNG file, name it slider.png and place it the same folder as the HTML code listed below.  Basically you should get what looks like a slider bar and the .PNG is the part you click on with your mouse and move back and forth on the bar.

The issue is this:  in the body section I have four <DIV> tags.  Two of these are self closing tags.  When they are self closing tags, you cannot see the majority of the .PNG image.  Change the two <DIV> tags to not be self closing and it displays correctly.

My question is WHY.  This works the same in all browsers so am I doing something wrong in my style?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <title>Slider Bar</title>
    <style type="text/css">

    .currentVal {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 10px;
    .sliderFrame {
            height: 38px;
            padding: 4px;
            border: 1px #000;

    .slider {
      top: -5px;
      background-image: url(slider.png);
    .sliderBar {
      position: relative;
      border-top-width: 1px;
      border-right-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      border-top-style: solid;
      border-right-style: solid;
      border-bottom-style: solid;
      border-left-style: solid;
      border-top-color: #666666;
      border-right-color: #FFFFFF;
      border-bottom-color: #FFFFFF;
      border-left-color: #666666;


<div   id="slider1-sliderFrame" style="width: 250px;"  class="sliderFrame">
  <div id="slider1-currVal"     style="left:  220px;"  class="currentVal">50</div>
  <div id="slider1-bar"         style="width: 213px;"  class="sliderBar" />
  <div id="slider1-slider"      style="left:   50px;"  class="slider" />

Watch Question
This problem has been solved!
Unlock 2 Answers and 2 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE