/    Sign up×
Community /Pin to ProfileBookmark

Does this over ride my css declaration?

Is this supposed to work cross browser?

p {
some attributes;
}

p.center {
text-align: center;
}

Does the default <p> tag with no class used still retain it’s css attributes? I’m seeing issues in old versions of Safari and on iphones (awesome mac’s)

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelAug 28.2007 — Is this supposed to work cross browser?

p {

some attributes;

}

p.center {

text-align: center;

}

Does the default <p> tag with no class used still retain it's css attributes? I'm seeing issues in old versions of Safari and on iphones (awesome mac's)[/QUOTE]


No, because "[COLOR="SeaGreen"][B]p {foo...}[/B][/COLOR]" affects only "[COLOR="SeaGreen"][B]<p>This is some text</P>[/B][/COLOR]" while "[COLOR="Red"]p.center {foo...}[/COLOR]" only affects "[COLOR="Red"]<p [B]class="center"[/B]>This is some additional text, -centered!"</p>[/COLOR]"

-The power of CSS!
Copy linkTweet thisAlerts:
@jtownauthorAug 28.2007 — Ok great. If I can't figure this iphone thing out I'll post up some code. ARgh.
Copy linkTweet thisAlerts:
@WebJoelAug 28.2007 — Okay. But the issue cited surely isn't the problem. ?
Copy linkTweet thisAlerts:
@YelgnidrocAug 28.2007 — Doesn't p.center inherit and use definitions from p unless p.center changes them.

e.g.

<i>
</i>
&lt;style&gt;

p {
color:red;
}

p.center {
text-align: center;
}

&lt;/style&gt;


&lt;/head&gt;
&lt;body&gt;
&lt;p class='center'&gt;hello&lt;/p&gt;
&lt;/body&gt;



You get a red centered hello.

Does the default <p> tag with no class used still retain it's css attributes?[/QUOTE]

I'd say yes, <p> will use "some attributes"
Copy linkTweet thisAlerts:
@macthewebAug 29.2007 — Attributes defined for p will be inherited by all paragraphs unless specifically overridden.

Attributes defined for p.center will not, and apply only to <p class='center'>

p.center can override defined p attributes.

p {color: red; font-weight: bold;}

p.center { text-align: center; color: blue;}

will display blue text but it will also inherit the bold font weight form the p style declaration.
×

Success!

Help @jtown spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...