Results 1 to 4 of 4

Thread: Need to shorten HTML code

  1. #1
    Join Date
    Jun 2015
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need to shorten HTML code

    I'm a novice at HTML and need help. We have this code and it takes up most of the allotted space in the field. Looking to shorten it.

    Here is the code:

    <a class="thumbnail" href="#thumb"><font style="color:#3399ff; font-size: 8pt; text-decoration:none;">View</font><span><img src="PD.jpg" /></span></a>

    Is all that necessary to accomplish the task? Can anything be shortened?

    Thank you in advance.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    It depends on what you're trying to do but it should be possible using just the <a> tag and CSS;

    HTML
    Code:
    <a class="thumbnail" href="#thumb">View</a>
    CSS
    Code:
    .thumbnail { display:inline-block; background:url(PD.jpg) 0 0 no-repeat; width:150px; height:150px; color:#3399ff; font-size:8pt; text-decoration:none; border:0 }
    You could also lose the "View" text and insert it via a pseudo element instead https://www.google.co.uk/search?q=ps...TqL4qrsgHPxqww

    If you need more help you'll need to show us a demo of what you have with a link to your page, and maybe a mockup image to illustrate.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jun 2015
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Click image for larger version. 

Name:	shorten code.jpg 
Views:	143 
Size:	30.0 KB 
ID:	5694

    Thank you so much for replying.

    I've attached a screen shot. When someone places their cursor over the word "view" then the picture comes up.

    This is an option in our shopping cart and the field is limited, so we were just wondering if there was anything we could do to shorten it.

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    This changes things.

    It might not be possible to reduced the markup if the CSS is targeting the span, so that the image is revealed on hover for example.

    Alternatively, JavaScript may be be targeting the span. That's something you'll need to look in to and will dictate what you can and can't change of the markup. Maybe try this instead?

    HTML
    Code:
    <a class="thumbnail" href="#thumb">View<span><img src="PD.jpg" /></span></a>
    CSS
    Code:
    .thumbnail { color:#3399ff; font-size:8pt; text-decoration:none }
    Have a play around with the sample code I provided and report back with your changes, along with a link if you need more help. It's impossible for anybody to help diagnose your problems without a page to test in.
    Last edited by Beverleyh; 06-19-2015 at 08:58 PM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Help needed to shorten some jacascript code
    By wtronic-germany in forum JavaScript
    Replies: 5
    Last Post: 03-23-2013, 05:20 PM
  2. Replies: 3
    Last Post: 05-12-2011, 03:43 AM
  3. Replies: 15
    Last Post: 06-11-2009, 12:27 PM
  4. Replies: 2
    Last Post: 10-27-2008, 05:16 AM
  5. Shorten your PHP Code, and make it easy.
    By Nile in forum Coding tips & tutorials threads
    Replies: 6
    Last Post: 06-26-2008, 07:23 PM

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
  •