camino
camino

Reputation: 10594

cannot change the attribute of article inside section

I want to change the attribute of article, but it seems it doesn't work if I also set the attribute for section. For example:

<html>
<style type="text/css">

section{
    margin:2px auto;
    background-color:green;
    border:2px solid blue;
    width:500px;
    height:10em;
};
/* will not work for article*/
article{        
    padding:auto;
    margin:2px auto;
    background-color:red;
    border:2px dashed red;
    width:100px;
    height:2em;
}
</style>
<body>
<section>
    <article>hello</article>
    <article>hello</article>
    <article>hello</article>
</section>
</body>
</html>

but after remove the css code for section, it will work:

<html>
<style type="text/css">
/*works now*/
article{
    margin:2px auto;
    background-color:red;
    border:2px dashed red;
    width:100px;
    height:2em;
}
</style>
<body>
<section>
    <article>hello</article>
    <article>hello</article>
    <article>hello</article>
</section>

</body>
</html>

I have test it on firefox22 and chrome 28.

Upvotes: 2

Views: 55

Answers (1)

ignacioricci
ignacioricci

Reputation: 1276

You have a ; after section {}, that's CSS invalid, so it breaks the following statement.

Remove it from you CSS declaration and tell me if it fixed your issue.

<style type="text/css">

section{
    margin:2px auto;
    background-color:green;
    border:2px solid blue;
    width:500px;
    height:10em;
} /* ; <-- remove it */


article{        
    padding:auto;
    margin:2px auto;
    background-color:red;
    border:2px dashed red;
    width:100px;
    height:2em;
}
</style>

Upvotes: 2

Related Questions