How to specify border and align in CSS file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AmberJain
    Recognized Expert Contributor
    • Jan 2008
    • 922

    How to specify border and align in CSS file?

    Hello,
    I know a bit of HTML and CSS. I'm designing my personal website. I want to put an image on one of my pages such that it has 'border' around it and it should be right aligned. And I want my website to conform to the standards. This page mentions that align and border attributes are deprecated and suggests that one should use styles instead.

    so, my question is:
    How to specify border and align attribute for images in styles? A related link to a good tutorial/article is also welcome.

    And yes, there's lot of crap (IE-oriented) stuff if I search google. So, I thought of posting here.

    Thanks...
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Fundamentally:
    Code:
    <style type="text/css">
    img{ float:right }
    </style>
    <img src="my_ugly_face.jpg" alt="Damn I'm Ugly">
    But that depends on what surrounds the image that can affect this.

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      I forgot about the border. To the css just add 'border:5px solid green' but there are quite a variety of things to do there.

      Comment

      • AmberJain
        Recognized Expert Contributor
        • Jan 2008
        • 922

        #4
        Thanks doc :) I will try that soon.

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Just to add, you can use clear: both; along with float: left; to make sure no other floating object ruins your layout.

          Comment

          Working...