473,511 Members | 17,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Taming Definition Lists, or Generated Content in IE

I recently came up with a cool little stylesheet [1] for definition
lists. There is a small demostration for the impatient [2]. I hope
this helps someone.

Here's how I did it. Definition lists are usually styled something
like:

] Term
] A tab of white space followed by the definition
] By
] Marcus Tullius Cicero
] L. Ipsum
] James Cerra
] Created
] Circa 45 BC
] Issued
] December 24, 2003

And so on. However, I wanted to style my definition list as [2]:

] Term: A tab of white space followed by the definition
] By: Marcus Tullius Cicero, L. Ipsum, James Cerra
] Created: Circa 45 BC
] Issued: December 24, 2003

These lists are displayed inline, with generated content added (i.e.
": " or ", " between multiple dd elements). This was relatively
simple to do for Mozilla or Opera with the following four blocks:

] dt, dd {
] display: inline;
] margin: 0;
] padding: 0;
] }
]
] dd + dt:before {
] content: "\000A";
] white-space: pre;
] }
]
] dt:after {
] content: ": ";
] white-space: pre;
] }
]
] dd + dd:before {
] content: ", ";
] }

However, Internet Explorer doesn't support CSS 2.1 generated content,
the "+" selector, or ":before" and ":after" pseudo-classes. I solved
this problem by using Microsoft's dynamic styles. I created a "dummy"
property and added a dynamic style which does something after the
element is first loaded (otherwise, it would be applied over and over,
until the browser crashed). Here's a simple example:

] -ie556-content: expression(
] this.parsed ? 0 : (aJavaScriptFunction(this), this.parsed=1)
] );

That will execute a JavaScript function on the element being styled
(referenced by the keyword, 'this') when it is first loaded. To add
the generated content in the specific contexts, I used another
conditional operator [3] with the DOM (W3C, Level 1) and a propitery
Microsoft function called "insertAdjacentText". You call it against
the object being modified [4]. It takes two arguments: The first is
a string that specifies where to place the new text ("beforeBegin",
"afterBegin", "beforeEnd", or "afterEnd"). The second argument is the
string to add.

Here's a practical example. The following is equivelent to the last
rule in my origional CSS (sorry about line breaks):

] dd {
] -ie556-content: expression(
] this.parsed ? 0 : (
] (previousSibling.nodeName == nodeName ?
insertAdjacentText("afterBegin",", ") : 0),
] this.parsed=1
] )
] );
] }

Here are my three content-generation CSS rules added translated as two
rules for IE:

] dt {
] -ie556-content: expression(
] this.parsed ? 0 : (
] (previousSibling ? insertAdjacentText("afterBegin","\\u000A") :
0),
] insertAdjacentText("beforeEnd",": "),
] this.parsed=1
] )
] );
] }
]
] dd {
] -ie556-content: expression(
] this.parsed ? 0 : (
] (previousSibling.nodeName == nodeName ?
insertAdjacentText("afterBegin",", ") : 0),
] this.parsed=1
] )
] );
] }
Check out my source for an easier to read version [1], [2]. I hope
that gives someone some ideas for their own stylesheets.

--
Jimmy Cerra

[1] http://www.pitt.edu/~jfcst24/2004/04/05/test.css

[2] http://www.pitt.edu/~jfcst24/2004/04/05/testx.html

[3] The the confused, a conditional operator in JavaScript takes the
form: "test ? doneIfTrue : doneIfNotTrue".

[4] i.e. The "this" object, but that's already the default scope, so
it is unnecessary to be added.
Jul 20 '05 #1
0 3523

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2634
by: Brett Selleck | last post by:
We have an issue where the JAXB generated classes are creating an interface which references itself. The Schema is valid, and I have not seen this ran into before. The code is below. What is...
6
2835
by: Stanimir Stamenkov | last post by:
So if the 'type' attribute of the OL element is deprecated and authors should rely only on stylesheets how one could use a reference (as clear text) in the content to a particular list element? ...
9
3734
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
7
4225
by: Neil Zanella | last post by:
Hello, I have posted the following message before but got no replies... I am trying to format an HTML definition list with CSS so that it appears as follows, but am having the following problem:...
9
1943
by: lists(nospam)at | last post by:
Howdy all, After following a tutorial on ALA (taming lists) I converted my navigation box from a table to a list. Generally very happy with it with the exception of IE6 on the Win platform...
2
2429
by: krsgoss | last post by:
I'm trying to do a two column "form" layout based on article here: http://www.alistapart.com/stories/practicalcss/ The idea is to have a label, and a value using definition list markup. I...
6
5026
by: mno | last post by:
Hi all, I have a problem that I've been stuck with for the last couple of days that's driving me a bit more than crazy at this point. Sorry if this message is not very clear. I have a design...
28
6010
by: hlubenow | last post by:
Hello, I really like Perl and Python for their flexible lists like @a (Perl) and a (Python), where you can easily store lots of strings or even a whole text-file. Now I'm not a...
4
3785
by: Steve Swift | last post by:
I'm trying to achieve a format of definition lists that matches the definition lists generated by IBM's "BookMaster" (from quite a few years ago). The effect is as if the terms and their...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.