Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    Use of margin/align?

    Hello

    I have the following CSS:

    Code:
    span.show_date { 
        
        font-size: 11px;
        font-family:verdana,arial,serif;
    
    }
    span.show_date sup {
        
        font-size:11px;
        font-family:verdana,arial,serif;
    }
    This formats the following date on a Web page:

    Code:
    <%@ Language="VBScript" %>
    
    <%
    Dim suffix
    Select Case Day(Date())
        Case 1,21,31: suffix = "st"
        Case 2,22: suffix = "nd"
        Case 3,23: suffix = "rd"
        Case Else: suffix = "th"
    End Select
    Response.Write "<span class=""show_date"">" & WeekdayName(Weekday(Date())) _
                 & " " & Day(Date()) & "<sup>" & suffix & "</sup> " _
                 & MonthName(Month(Date())) & "</span>"
    %>
    However, this does not position the date on the page (I would like it to be a few px from the right-hand side (use of margin?), whereas now it is stuck in the top left-hand corner). A previous poster kindly suggested using a <span> inside a <div> because you cannot position text using a <span> on its own, but I am at a loss about how to do that, and I am just wondering if <table> would overcome this problem?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    No do not use a table. It is not the solution to this problem. You don't even need the span
    Code:
    Response.Write "<div class=""show_date"">" & WeekdayName(Weekday(Date())) _
                 & " " & Day(Date()) & "<sup>" & suffix & "</sup> " _
                 & MonthName(Month(Date())) & "</div>"
    Code:
    div.show_date {
    text-align:right;
    font-size: 11px;
    font-family:verdana,arial,serif;
    }
    div.show_date sup {
    margin-right:-10px;
    }
    You also don't even need this CSS
    Code:
    span.show_date sup {
    
        font-size:11px;
        font-family:verdana,arial,serif;
    }
    The font size and family get inherited from the parent element. It was as hard as you thought it was.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    SteveH (05-15-2012)

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello Aerospace

    Cheers for that - you have substituted <span> for <div>, haven't you?

    It works a treat and looks nice.

    Many thanks.

    Steve

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Yes as the span wasn't adding any value to the HTML. It really served no purpose.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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