SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru redhillccwebmas's Avatar
    Join Date
    Jun 2005
    Posts
    989
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to specify dimensions of Img Src in HTML so that page can be XHTML strict

    Hi there,

    I have encountered a problem when trying to get my page to validate to XHTML Strict - currently I am controlling the size of an image within the HTML. I am only doing this because I have a load of images and I am controlling them through a database and don't want to have to create duplicate images in thumbnail size - is there anyway around this problem?

    My page is at http://www.jh-webdesign.co.uk/test

    Thanks

    James

  2. #2
    SitePoint Wizard trampt's Avatar
    Join Date
    Jan 2003
    Location
    Los Angeles, CA
    Posts
    1,997
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use widths and heights in your img tag ... just wrap them in quotes

    height=95px is bad and works in transitional
    height="95px" is XHTML strict

    Skimming your code there was an instance where you don't even have an equal sign. Just clean up your code and you'll be fine.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit: bah, trampt beat me to it.

    Use height="95" instead of height=95px (same for width). Also, you have the code
    Code:
    <img height=95 width 95 src="images/services/SEO.jpg"
    (missing the = for width).

    Also, I would highly recommend generating thumbnails for your images and storing them in the database as well. You'll save a lot of bandwidth, but more importantly, your client's load times will be much lower because they won't have to load a huge image only to have it scaled down client side.

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trampt
    height=95px is bad and works in transitional
    height="95px" is XHTML strict
    No, the first one is invalid XHTML no matter which DTD. In XHTML, all attribute values must be enclosed in quotes.

    There should be no 'px' in the attribute value, either. Presentational attributes in (X)HTML are in pixels (or percent).

    Thus:
    Code:
    height="95"
    Birnam wood is come to Dunsinane


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
  •