Results 1 to 8 of 8

Thread: text height

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default text height

    Hi, I wasn't sure what to name this topic, but I am trying to use css to write a sentence where one word in the middle of a sentence is of a different font, color, and size than the other words in the text, but also about 5px elevated than the other words while remaining on the same line.

    I am hoping to do this with minimal divs, but use of any css is fine.
    Last edited by james438; 04-15-2011 at 04:08 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    You could probably use the sup with a class and apply the following css attributes to it line-height, color, font-family.

    Code:
    This <sup class="that_word">one</sup> word.
    Code:
    <style ="text/css">
    .that_word {
    color: #f00;
    font-family: Arial, Times, Serif;
    line-height:5px; /* this maybe/is wrong */
    }
    </style>
    Corrections to my coding/thoughts welcome.

  3. The Following User Says Thank You to bluewalrus For This Useful Post:

    james438 (04-15-2011)

  4. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Thanks, I was not aware of the sub and sup tags. It helps, but is still not quite right. Take a look at the following:
    Code:
    <body>
    This <sub class="that_word">→</sub> word.
    </body>
    <style ="text/css">
    .that_word {
    color: orange;
    font-family: Arial, Times, Serif;
    vertical-align:text-bottom;
    font-size:24px;
    line-height:777px;
    font-weight:bold;
    }
    body{background-color:blue;
    color:white;}
    </style>
    For some reason the surrounding text is affected as well. Try the code without the highlighted line as well and you will see an interesting change.

    Ideally, I would like to be able to raise and lower the word, or in this case arrow, with pixel precision and if I raise or lower it high enough it will overlap with the text above or below. In other words raising the word will not interfere with the text above it.
    To choose the lesser of two evils is still to choose evil. My personal site

  5. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Got it.

    Code:
    <body>
    This <sub class="that_word">→</sub> word.
    <br>here is some more text.
    </body>
    <style ="text/css">
    .that_word {
    color: orange;
    font-family: Arial, Times, Serif;
    position: relative;
    top:-5px;
    font-size:24px;
    font-weight:bold;
    }
    body{background-color:blue;
    color:white;}
    </style>
    Found the answer here.
    Last edited by james438; 04-15-2011 at 12:32 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  6. #5
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default

    nice, thanks for sharing. i never mention about that tag too.
    _____________________

    David Demetrius // davejob
    _____________________

  7. #6
    Join Date
    Jan 2011
    Location
    England
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You could also use the <span> tag if you wish. Just give the <span> and "id" and in your CSS just set your properties. =D

  8. #7
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    The <span> and <sub> tags operate slightly differently, but yes, I do like using the span tag more. Thanks for the tip LearningCoder.

    If I were to improve upon this a little further I would like to make the increased font size of the word not displace the upper and or lower lines of text and even overlap them if the tagged text were large enough to do so, but I am quite happy with this the way it is. This will give me many more options with manipulating text.
    To choose the lesser of two evils is still to choose evil. My personal site

  9. #8
    Join Date
    Jan 2011
    Location
    England
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No problem.

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
  •