Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: explain div

  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Location
    India,Tanuku,A.P
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    explain div

    I am a php programmer,working with ajax applications,in it for the display they used div
    shall iknow how to use div?
    can anybody send the code to store a image in div.and the magics of div?

  • #2
    Regular Coder Jutlander's Avatar
    Join Date
    Jun 2007
    Location
    In my own sick little world :P
    Posts
    425
    Thanks
    1
    Thanked 12 Times in 12 Posts
    Well, a div is a block level element so you can pretty much place anything inside it and yes it's a very useful tag to know. Remember that it doesn't do anything on its own, but must have a class or an ID assigned to it. You then style the class or ID with CSS.

    One way to "store" your image in the div would be to give it a background image.

    Code:
    #IDname {
    background: url(image.gif);
    height: 100px;
    width: 150px;
    }
    You would then call it with:

    Code:
    <div id="IDname"></div>
    .
    .

  • #3
    New to the CF scene
    Join Date
    Aug 2007
    Location
    India,Tanuku,A.P
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank u
    if i want to write any thing in the div,i have to use
    document.getElementById().innerhtml.[for the text]
    and for the
    image what i have to do?
    The problem of mine was i have to show the image,from the server in the div tag
    then i got the prob
    can u refer any url for me ,or any advise.
    Thanks for sparing u r time for me,

  • #4
    Regular Coder Jutlander's Avatar
    Join Date
    Jun 2007
    Location
    In my own sick little world :P
    Posts
    425
    Thanks
    1
    Thanked 12 Times in 12 Posts
    You may place what you like in a div:

    Code:
    <div id="IDname">
    
    <h1>My first heading</h1>
    
    <p>A paragraph</p>
    
    <img src="path_to_image.gif" alt="This is an image">
    
    </div>
    This will all be put over the background image. You might want to look into this: http://www.w3.org/TR/html4/struct/global.html#h-7.5.4
    .
    .

  • #5
    New to the CF scene
    Join Date
    Aug 2007
    Location
    India,Tanuku,A.P
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank u jutlander ,Take care

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    DIV is short for division or divider and its intended use is to divide up the content of the page into separate sections.

    The main uses are

    1. with an id to break the page up into sections eg.
    <div id="header"></div>
    <div id="navigation"></div>
    <div id="content"></div>
    <div id="footer"></div>

    2. with a class to use as block level tags which do not have a semantically valid block level tag already defined for them. You would then use a descriptive class name to define what the tag would be that you would be using if such a tag existed.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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