www.webdeveloper.com
Results 1 to 8 of 8

Thread: Putting style (CSS) within div tags

  1. #1
    Join Date
    Aug 2011
    Posts
    38

    Question Putting style (CSS) within div tags

    Hi All,

    I need to put the css attributes inside my div tags. The css cannot be inside the <head> tags, and it cannot be called from a separate file. It needs to be inside the <body> tags with the <div> tags.

    Can anyone show a example of how to accomplish this? The main things I need is - Div height, Div width, Font size, Font color, image source.

    THANK YOU SO, SO MUCH FOR YOUR HELP!!!!

  2. #2
    Join Date
    Aug 2006
    Posts
    1,943
    It's called "inline CSS", like this:
    Code:
    <div style="height:100px;width:200px">
    blah
    </div>
    Dave

  3. #3
    Join Date
    Aug 2011
    Posts
    38
    Thank you so much! It's been a long time since I had to do this, and I don't do web coding that often, so I couldn't remember for the life of me. lol.

    Thank you again.

  4. #4
    Join Date
    Aug 2011
    Posts
    38
    How about if you want to add css rules for links? Such as link, visited, hover, etc...

    Thanks,

  5. #5
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by Sribeiro View Post
    How about if you want to add css rules for links? Such as link, visited, hover, etc...

    Thanks,
    Would this work?
    Code:
    <style>
    /* rules go here */
    </style>

  6. #6
    Join Date
    Aug 2011
    Posts
    38
    Sorry, I'm not understanding...
    If I have something like this -
    <style="background-color: #036; height: 16px;"></style>

    How do i add the link rules to the above style rule?

    Thanks so much for your help.

  7. #7
    Join Date
    Aug 2006
    Posts
    1,943
    You cannot style a selector like a:hover with inline styling like you asked above for the <div>. But if you can edit in the <head> section of your code, then that is always preferable over inline, and you could do it there as Criterion has suggested...

    Code:
    <style type="text/css">
       a:hover {color:#B00}
    </style>
    Dave

  8. #8
    Join Date
    Mar 2012
    Posts
    48
    here is threee ways to insert css to your html

    http://www.w3schools.com/css/css_howto.asp

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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