www.webdeveloper.com
Results 1 to 7 of 7

Thread: Styling an Individual Element Already Styled in a Stylesheet

  1. #1
    Join Date
    Jul 2008
    Posts
    26

    Styling an Individual Element Already Styled in a Stylesheet

    Hi, I have a list of tabs the headers (H2) of which are styled in a stylesheet, I now want to style an individual tab to be a certain color but cant seem to be able to do this.
    When I set the color locally the stylsheet style overides anything?

    HTML

    Code:
    <div class="tabber">
    
    	<div class="tabbertab">
    
    		<h2>Title I want to change</h2>
                    <p>Content
    		</p>
    		
    	</div>
    
    	<div class="tabbertab">
    
    		<h2>Title 2</h2>
                    <p>Content
    		</p>
    		
    	</div>
    
    	</div>
    CSS

    Code:
    .tabberlive .tabbertabhide {
    	display: none;
    	}
    
    .tabber {
    	padding: 0px;
    	}
    
    .tabberlive {
    	margin-bottom: 10px;
    	}
      
    ul.tabbernav {
    	margin: 0;
    	padding: 0px 0;
    	color: #202020;
    	font-size: 12px;
    	font-family: Arial, Tahoma, Verdana;
    	font-weight: normal;
    	}
    
    ul.tabbernav li {
    	list-style: none;
    	margin: 0;
    	display: inline;
    	}
    
    ul.tabbernav li a {
    	padding: 3px 0.5em;
    	border-bottom: none;
    	text-decoration: none;
    	}
    
    ul.tabbernav li a:link {
    	color: #202020;
    	background: #DDDDDD;
    	margin: 0px 5px 0px 0px;
    	}
    	
    ul.tabbernav li a:visited {
    	color: #202020;
    	background: #DDDDDD;
    	}
    	
    
    ul.tabbernav li a:hover {
    	background: #666666;
    	color: #FFFFFF;
    	text-decoration: none;
    	}
    
    ul.tabbernav li.tabberactive a {
    	background: #333333;
    	color: #FFFFFF;
    	text-decoration: none;
    	}
    
    ul.tabbernav li.tabberactive a:hover {
    	background: #333333;
    	color: #FFFFFF;
    	}
      
    .tabberlive .tabbertab {
    	background: #FFFFFF;
    	padding: 10px 0px 0px 0px;
    	}
    	
    .tabberlive .tabbertab h2 {
    	display: none;
    	}
    	
    .tabberlive .tabbertab h3 {
    	display: none;
    	}
    
    .tabbertab cite {
    	font-size: 11px;
    	margin: 0px;
    	padding: 0px;
    	}
    How could I set the H2 Title so I could style just that one?

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Give it a class or id
    The following will work in modern browsers, except IE
    Code:
    .tabber .tabbertab:nth-of-type(1) h2 {color:red;}
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Aug 2006
    Posts
    1,886
    (deleted, didn't work at all )
    Last edited by tracknut; 01-06-2010 at 09:13 AM.

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by millsy007 View Post
    When I set the color locally the stylsheet style overides anything?
    Yes. You may style it locally. Not an elegant solution, but a sure one.
    Last edited by Kor; 01-06-2010 at 10:28 AM.

  5. #5
    Join Date
    Jul 2008
    Posts
    26
    Hi the problem is even when I change the header locally the css overides the style, ie:
    <h2 style="font-size:18px; color:red">
    Doesnt make a difference
    The tabber section is using javascript to set css styles dynamically could this be a factor?

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Yes, the JavaScript will be overriding the style.
    Give a link or full code.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  7. #7
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Code:
    .tabber .tabbertab { all of them }
    .tabber .tabbertab:first-child{ first one only}

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles