+ 1
This beginner has a problem with css
Here's the html : <P>First Text</P> <div id="text"> <h1>Title<h1> <p>Second Text</p> </div> and here's the css : p{text-align: left;} #text{text-align: center;} I want to make the whole div center-aligned but the <p>Second text<p> is still left-aligned because it's p element. Is there any other way to style the second text without making another line in css : #text p{text-align: center; ?
2 Antworten
+ 2
assuming that the <body> tag is the container of your code sample, you could modify your first css rule selector:
body > p { text-align: left; }
... this will restrict the property to only <p> direct children of <body>, and let deepest <p> inherit from their ancestors ;)
Obviously, you could also define and set a css class ^^
+ 1
width:100%;