-1

I'm trying to get the same result as this question, but unable to. I would add a comment, but I don't have enough reputation.

Here's my current code.

dl {
  width: 400px
}

dt {
  float: left;
  width: 300px;
  overflow: hidden;
  white-space: nowrap
}

dd {
  float: left;
  width: 100px;
  overflow: hidden
}

dt:after {
  content: " .................................................................................."
}
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">

<dl>

  <dt>Drug 1</dt>
  <dd>10ml</dd>

  <dt>Another drug</dt>
  <dd>50ml</dd>

  <dt>Third</dt>
  <dd>100ml</dd>
  
</dl>

</html>

When I try HTML5, <!DOCTYPE html><html>, it doesn't work at all!

What code will work with the following DOCTYPE?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Chris Happy
  • 7,088
  • 2
  • 22
  • 49
Stackoverflow
  • 449
  • 5
  • 13
  • The first doctype you show is the current one for all new web pages and is required. The second one you show is for XHTML only. You shouldn't be using the second one because I'm sure you aren't serving XHTML despite the XML prologue in your markup. What you show is a mish-mash of markup that is confusing. – Rob Jul 12 '17 at 03:27

1 Answers1

5

You need to:

  • wrap each of them sections with dl
  • add the CSSdd { margin: 0 }

dd {  margin: 0  }

dl {
  width: 400px
}

dt {
  float: left;
  width: 300px;
  overflow: hidden;
  white-space: nowrap
}

dd {
  float: left;
  width: 100px;
  overflow: hidden
}

dt:after {
  content: " .................................................................................."
}
<dl>
  <dt>Drug 1</dt>
  <dd>10ml</dd>
</dl>

<dl>
  <dt>Another drug</dt>
  <dd>50ml</dd>
</dl>

<dl>
  <dt>Third</dt>
  <dd>100ml</dd>
</dl>
Chris Happy
  • 7,088
  • 2
  • 22
  • 49