473,387 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

centred text / css selector precedence

I am having a problem with this page:-

http://www.bytronic.com/tests/centre.html

I want a nice centred paragraph, but get a justified paragraph. I
expected the .centre to override the #content p, as it is later in the
css file, but it doesn't.

The reason I have both these rules in the css is because in general
paragraphs in the content section of our pages should be justified, but
some are centred instead, so get their own class.

Thankyou for your help,

Martin

--
Martin Eyles
ma**********@NOSPAMbytronic.com
(posting as ma**********@NOSPAMntlworld.com from google because the
news server is down)

Dec 22 '05 #1
6 2234
ma**********@ntlworld.com wrote:
I want a nice centred paragraph, but get a justified paragraph. I
expected the .centre to override the #content p, as it is later in the
css file, but it doesn't.


#content p is more specific then .centre so it takes priority.

#content p = 101
..centre = 010

http://www.w3.org/TR/CSS2/cascade.html#specificity

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dec 22 '05 #2
Im not sure why it doesnt overwrite the first style, but if you do
this:

.centre {text-align: center !important; }

it will use that rule instead.
Adam
http://www.adamrisser.com

Dec 22 '05 #3
"David Dorward" <do*****@yahoo.com> wrote
http://www.w3.org/TR/CSS2/cascade.html#specificity


Thank you for explaining why this happens...

--
Martin Eyles
ma**********@NOSPAM.bytronic.com
(yay, the news server be fixed)
Dec 22 '05 #4
"Adam Risser" <ar*****@gmail.com> wrote
.centre {text-align: center !important; }


.... and thank you for explaining how to fix it.

--
Martin Eyles
ma**********@NOSPAM.bytronic.com
(yay, the news server be fixed)
Dec 22 '05 #5
Adam Risser wrote:
Im not sure why it doesnt overwrite the first style, but if you do
this:

.centre {text-align: center !important; }

it will use that rule instead.
Adam
http://www.adamrisser.com


or depending on how you want to structure things add

#content p.centre {text-align: center}

Stuart
Dec 22 '05 #6
On 2005-12-22, Adam Risser <ar*****@gmail.com> wrote:
Im not sure why it doesnt overwrite the first style, but if you do
this:

.centre {text-align: center !important; }

it will use that rule instead.


I thought !important meant "not important" to IE.
Bye.
Jasen
Dec 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: techy techno | last post by:
hiii I wanted to know how can I check for a specific HTML tag or user defined TEXT and delete it when the page loads Whenver the IE loads the page my company add its COMPANY NAME in my office...
6
by: Richard Barnet | last post by:
Dear CSS gurus, My question regarding 'the cascade' is a simple one, but one that I haven't heard anyone talk about before: When cascading (for instance, when applying two linked stylesheets),...
3
by: Jonah Bishop | last post by:
I have a puzzling problem with centering text, and I'm hoping that someone here can help me out. First of all, let me state that I am using XHTML 1.0 Strict and CSS for all layout purposes (no...
13
by: arreeess | last post by:
i wont used three styles in the element of a list; i have does so: <ul> <li> ............................. </li> first style <li> <p> .....................</p> </li> 2° style <li> <p...
1
by: John Rowe | last post by:
I run the web site for a University department. A few of my authors will carefully write: <h3>Title</h3> <p>Some text here.</p> <p>Second paragraph.</p> Most of us can't be bothered(!): ...
2
by: Chris Sharman | last post by:
See http://services.ccagroup.co.uk/testform.htm Looks as intended in firefox, is valid (bulk of inputs centred in a div occupying the left half of the page). ie ignores the child selector,...
17
by: Alan Silver | last post by:
Hello, If you look at http://www.kidsinaction.org.uk/Thumbs.html you will see a simplified version of a page that could be used to display thumbnail images of various products. Now, due to...
5
by: Jim Garrison | last post by:
In reading someone else's stylesheet I ran across the following two selectors, in the following order. #footer .label { ... } #footer .label { ... } Are these not identical in effect? If...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.