0

In my firefox extension I created a div element and added to it a paragraph with id named myP.

In the css file I wrote:

#myP
{
    color: red;
    text-align: center;
    font-size: 16px;
    font-weight: 900;
    margin: 7px 7px; 
} 

but only the first two properties applied to the paragraph.

I tried to set the three others properties in my js code:

myP.style.fontSize = "16px";
myP.style.fontWeight = "900";
myP.style.margin = "7px 7px";

and it worked perfectly.

how can it be?

3
  • It worked for me, though having said that p elements aren't supposed to contain block elements like divs. Can you demonstrate the problem with a jsfiddle? Commented Mar 2, 2012 at 11:46
  • Manatok already solved it, thanks anyway. I think I did not understand you well, the p element is inside the div not the opposite Commented Mar 2, 2012 at 11:51
  • My apologies, I misread your question vis-a-vis which element was being added to which. I guess Manatok's answer also explains why it worked for me: I didn't have any other styles set that could clash. Commented Mar 2, 2012 at 11:57

1 Answer 1

2

Maybe there is something else that is overriding your styles, can you inspect it in any way?

Have you tried:

#myP
{
    color: red;
    text-align: center;
    font-size: 16px !important;
    font-weight: 900 !important;
    margin: 7px 7px !important; 
} 
Sign up to request clarification or add additional context in comments.

1 Comment

you are right. it is working now, thanks! is it because maybe in the page's css file there is these properties to all p elements?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.