Hi guys, I need a good tutorial to learn how to use external sheets and how to link to them from the HTML page. Any good link? Thx
Link to them using: <link rel="stylesheet" type="text/css" href="stylesheet.css" /> Code (markup): The best way to learn is to just open up the CSS file of a site and look at it.
All you really need is to take a text editor and save a file to .css, then link to it using the code provided above. Then, any styles you would have embedded, simply put them in the external file instead.
I would like to ask a specific question. If I have an image and I want to align it at the center I may do it with tables, but how can it be done with div tags, using css?
yes but how can I insert it within the style? aomething like the following? <style> .alignimage{ align:center; } </style> .... <div class="alignimage" id="image">.......</div>
You were talking about an external sheet. Save a blank file in notepad (or any other plaintext editor), and then insert the following into it: img.stylename { margin: auto; } and save it. Then just give your image the attribute class="stylename" .
Well, for starters, <img> is an inline element, so it's going to be treatd as regular text. If the element's parent is the <body> tag, then you're going to have to wrap it in a DIV container, like so: <body> <div><img src="#" width="200" height="150" alt="Alternative Text"></div> </body> Code (markup): The DIV container will take up the full width of the browser window, since it's a block-level element, so you're going to want to declare this in your stylsheet: div { height: 150px; margin: 0 auto; padding: 0; width: 200px; } Code (markup):