[thelist] Styling JavaScript created paragraph

Julian Rickards julian.rickards at gmail.com
Sun Oct 22 14:26:58 CDT 2006

Hmm, I think I have answered this.

I looked in Firefox's DOM Inspector and a paragraph with the id of
description does exist (it must be generated because it is not in the HTML

It is still not clear to me whether or not I can use CSS to style generated
content or whether it must be done, as you had shown, using JS.


On 22/10/06, Julian Rickards <julian.rickards at gmail.com> wrote:
> If the JS code is:
>   var para = document.createElement("p");
>   para.setAttribute("id","description");
> doesn't this generate (thanks) a paragraph with the id of description and
> should I be able to style it in the stylesheet?
> Like I said, I may have messed with something else but if I am correct
> above, then I can search for whatever else I may have messed up.
> Jules
> On 22/10/06, Christian Heilmann <codepo8 at gmail.com> wrote:
> >
> >
> > There is no difference between Paragraphs and generated Paragraphs.
> > Both the set Attribute lines are invalid. If you want to do that in JS
> > you need to set
> > document.getElementById('description').style.textAlign='center';.
> > However, only MSIE6 centers images with the text flow. If you want to
> > do it in other browsers, use margin:0 auto; and display:block to
> > center an image.

Website: http://jrickards.ca
Blog: http://pen-and-ink.ca

More information about the thelist mailing list