Solved

How to get around a css *

Posted on 2012-12-31
12
253 Views
Last Modified: 2013-01-01
I was asked to create a page for a client at http://www.aleh.org/eng/marathon.asp. The page uses a CSS at www.aleh.org/eng/css.css with has a * selector. I want to redefine the font-size of the <h2> selector for this page, but the * selector always seem to override it. I've tried !important without any change in behavior, as well as an id selector.

How can I redefine the size and color of the <h2> selector tag on this page without modifying the site-wide CSS file?

Thank you.
0
Comment
Question by:Lev Seltzer
  • 4
  • 3
  • 2
  • +3
12 Comments
 
LVL 16

Expert Comment

by:rbudj
ID: 38732520
If you just want to override it for this page, use an inline style on each <h2>

<h2 style="font-size:24px; color:#000000;"></h2>
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38732591
If you have
h2 {font-size:24px; color:#000000;}

In a stylesheet that is in the listing order after the global (*) declaration, the the more specific declaration will prevail.  If it does not, then the global declaration is not the actual problem and you need to post a link so we can look at the page and see what is being applied to the h2.

Using inline styling is not a good idea as it starts to make the page more difficult to maintain.

Cd&
0
 

Author Comment

by:Lev Seltzer
ID: 38732606
I also do not want to use in-line styles.
The links to the page and the CSS are in the original posting.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38732629
Have you tried using the !important modifier?
0
 

Author Comment

by:Lev Seltzer
ID: 38732638
current style on the  http://www.aleh.org/eng/marathon.asp is:
#marathon h2 {color:green !important;font-size:30px !important;}

So yes, I am using !important.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38732652
My mistake. I completely glossed over your mention of that in the OP.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38732770
The page is a mess.  Even when I bypass the invalid styling before the HTML tag it gets 59 errors in the validator.  There is no point trying to get control of the styling in a page with that many error.  Fix the page, and then a logical approach to fixing the styling issue will be more likely to work.

Cd&
0
 

Author Comment

by:Lev Seltzer
ID: 38732875
COBOLdinosaur: I come to this site to get help. If you want to help me by suggesting that I correct page errors first, then I appreciate that. In fact, I was able to correct most of the errors in the past few minutes.

However, please do not negate my webpage and my question. You are not required to answer the question. If you feel that you cannot give an answer due to the invalid page design, then please just ignore my question.

I personally feel that this is a minor problem and that someone out there can come up with a work-around.

Thank you.
0
 
LVL 17

Expert Comment

by:nanharbison
ID: 38733166
WEBuilder - Coboldinosaur wasn't particularly tactful in his suggestion, but he is right that you needed to fix the errors before solving the CSS. The errors mess up the CSS.

You have to make sure your new CSS rule is after the * rule as the browser will obey the last rule it finds. Or try giving the body an ID or class (or a div or span or something) on this page and then assign your h2 to that element.
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 38733321
The first h2 tag is the word "About" over the first paragraph in the middle of the page. The word "About" is also a link. The <a> tag inside the <h2> tag is overriding the h2 style. Try including the <a> tag in your override style.
#marathon h2, #marathon h2 a {color:green !important;font-size:30px !important;}

Open in new window

0
 

Author Closing Comment

by:Lev Seltzer
ID: 38733383
Perfect. I figured it was just a simple styling error on my part. Thank you for your quick response and simple solution.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38734343
WEBuilder,

If you post in the topics where I am active and you have errors in the code, they will be pointed out.  Most of the people I help on this site are professional enough to accept the criticism as part of the learning process.  

If you prefer to make your work more difficult by not validating as the first step in problem solving, then you can expect to hear about it here, instead of from your clients when one of the errors jumps up and trashes a site.

Cd&
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS to create a button that has inward arrows at both ends 1 38
Help to align the buttons in a row 2 51
Box Locations 6 25
Why a span is lower 2 29
Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question