Results 1 to 9 of 9

Thread: <img/> or CSS

  1. #1

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Wink <img/> or CSS

    What is the best way to add an image to a web page, if I want to load up the page quickly?

    Using traditional <img/> tag or through CSS file…..
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: <img/> or CSS

    I dont think there is a difference. What you will want to do is make the image optimized for smaller size and only loose a minimal amount of quality that is acceptable to you.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: <img/> or CSS

    There is no speed difference, however there is a semantic difference.

    Use an image element if the image is relevant to the page content. The page should make sense with CSS disabled.

    Use a CSS background-image property if you're just adding visual effects to the page that have no bearing upon the content.

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: <img/> or CSS

    PNG is very good for graphics that don't have many colors or that have colors that blend nicely together. There are optimizers that minimize the file size.

    GIF works the best for the smallest and least colorful graphics (ie. two or 16 color graphics).

    JPEG works for everything else.

    Another thing that affects page loading is the amount of files: less files to load is usually better with slow connections. Loading from one server is also faster than loading from two or more servers. With fast connections you can't really see the difference.

  5. #5
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: <img/> or CSS

    One more thing, using a <img> tag gives you the opportunity to enhance your page's SEO by providing a description in the alt attribute
    Chris

  6. #6

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: <img/> or CSS

    Quote Originally Posted by RobDog888
    I dont think there is a difference. What you will want to do is make the image optimized for smaller size and only loose a minimal amount of quality that is acceptable to you.
    If the image is too large I can cut it into small parts, isn't it
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  7. #7

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: <img/> or CSS

    Quote Originally Posted by Merri
    GIF works the best for the smallest and least colorful graphics (ie. two or 16 color graphics).
    Correct

    All the time use GIF. Easy to work with it, even on the paint.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  8. #8
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: <img/> or CSS

    Quote Originally Posted by eranga262154
    Correct

    All the time use GIF. Easy to work with it, even on the paint.
    MS Paint for graphic design????

    /me calls the men in the white jackets.
    Chris

  9. #9

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: <img/> or CSS

    Quote Originally Posted by the182guy
    MS Paint for graphic design????

    /me calls the men in the white jackets.

    Just for the simple design, like a icons or a small images.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width