Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9

Thread: CSS question

  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    42
    Member #
    2955
    I can't figure out how to apply a css class to certain parts of text in a body. For instance this is my body text:

    I think web design forums is a great place to learn all aspects of web design with friendly and knowledgeable people who are here to help one another. Thanks for such a great place.

    Here is my css sheet:

    .body {font-family: arial, helvetica, sans-serif;
    font-size: 10pt;
    font-weight: bold;}

    If I wanted to apply the body class to the text "web design forums", how do I do just that part of the body text?

  2.  

  3. #2
    Junior Member
    Join Date
    Dec 2003
    Posts
    1
    Member #
    4190
    Just add the class in the font tag as shown:

    <font class="body">web design forums</font> or
    <span class="body">web design forums</span>

    Personally, i prefer the 1st one. The code is cleaner.

  4. #3
    Senior Member Riat_Sila's Avatar
    Join Date
    Oct 2003
    Location
    Berkshire, UK
    Posts
    417
    Member #
    3485
    Surely you could just use a <strong> tag as all you're doing is making the text bold...

  5. #4
    Senior Member mossoi's Avatar
    Join Date
    Apr 2003
    Location
    Englandshire, United Kingdomsville y'all!
    Posts
    1,111
    Member #
    1206
    Liked
    1 times
    Adding <strong> would mean that the formatting would be incuded within the page itself which is something to avoid. It's always best to avoid any inline formatting to make the pages easier to change later on.

    This isn't so important when there is only one page but when there are more, and there is more text that needs to be formatted, the stylesheet allows these changes to be made from one point rather than wading through all the code.

    Also I don't think <strong> is XHTML supported.

    It's good practice even on a small site to avoid inline formatting.

  6. #5
    Senior Member Riat_Sila's Avatar
    Join Date
    Oct 2003
    Location
    Berkshire, UK
    Posts
    417
    Member #
    3485
    <strong> is xHTML supported, so there

  7. #6
    Senior Member mossoi's Avatar
    Join Date
    Apr 2003
    Location
    Englandshire, United Kingdomsville y'all!
    Posts
    1,111
    Member #
    1206
    Liked
    1 times
    Fair enough but it's still 'not as good practice' to put text formatting within the body of a page.

  8. #7
    Senior Member dotcommakers's Avatar
    Join Date
    Oct 2003
    Posts
    527
    Member #
    3342
    Liked
    1 times
    in short...

    in short...

    put all format tags.. in CSS so whenever you want to change look it will be easy for you by channging... in just CSS

  9. #8
    Member
    Join Date
    Sep 2003
    Posts
    42
    Member #
    2955
    This is not just for the bold tag, it was just used as an example. It was meant for any tags.

  10. #9
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    Anyway, It's not true that all he's doing is making the text bold... he's also making it 10px in size and sans-serif.

    Personally, I would be inclined to avoid having custom definitions with names like .body { } as it could cause confusion with the body { } definitions later.

    Sean


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:35 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com