SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking coding h1 headers

    For a homework assignment I have to put the style code in the head to make all h1s a specific color and aligned to the center. I know how to make all of the h1s a specific color, but I am having a hard time figuring out how to align it to the center. and THEN I have to override that code to make one of the h1's a different color and aligned to the right. I don't know how to do that either. Any help would be very appreciated!! Does anyone know a good site that explains this? Or can someone just post to explain it? Thanks!!

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Ruthie817 View Post
    I know how to make all of the h1s a specific color,
    show us what css you've got so far, and be sure to include some of the html
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru james_littler's Avatar
    Join Date
    May 2007
    Location
    Portsmouth, UK
    Posts
    775
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    h1{
    color:#000000;
    font-family:Arial, Helvetica, sans-serif;
    font-size:1.2em;
    }


    <h1 align="center">riwegnuiwn</h1>


    to over ride just use inline

    ie
    <h1 align="center" style="color:#cccccc; font-family:'Times New Roman', Times, serif; font-size:2em" >riwegnuiwn</h1>

    heirachy

    1, inline style
    2, head style
    3, seperate style sheet

    inline always takes precidence

  4. #4
    SitePoint Guru redhillccwebmas's Avatar
    Join Date
    Jun 2005
    Posts
    989
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    'align' is a depreciated inline attribute. Your best to use text-align:center in your css instead

  5. #5
    SitePoint Wizard bronze trophy DaveWoods's Avatar
    Join Date
    Dec 2004
    Location
    Derbyshire - UK
    Posts
    2,651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And also to overide the style you'd be better off applying a class or ID to the <h1> tag and applying it that way.

    I'd never suggest applying styles inline as that goes in the face of separating style from content.

    Keep everything in an external CSS file if possible.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code CSS:
    h1 {
      color: #c00; /* or whatever */
      text-align: center;
    }
     
    h1.special {
      color: #060; /* or whatever */
      text-align: right;
    }

    Code HTML4Strict:
    <h1>Normal Page Heading</h1>
    ...
    <h1 class="special">Right-Aligned Page Heading</h1>
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Guru redhillccwebmas's Avatar
    Join Date
    Jun 2005
    Posts
    989
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On a seperate note, Tommy, really enjoyed listening to the two podcasts featuring yourself and Eric Meyer- nice job

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! Sara did a great job hosting it, and I really enjoyed being the co-host. Eric is a delight to talk to.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

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