Styles are one way you can format your text and images. Most styles should go in the header of the HTML page. However, if you have a Clubspaces site, you don't have access to the page headers, so we use what are called inline styles. Inline means that the style is applied directly to the element instead of in a separate location. Here's one way to format your page with styles (CSS) to get a nice format:
FLOATING IMAGES
Say you have an image and you want your text to wrap around the image; similar to a magazine or newspaper style. You could use a table to format it, but it's not always precise and can get messy. Styles can make this work very easily with just a few simple words.
Here is a
basic image tag: <img
src="myimage.jpg">
To float
this image, you would add the BOLDED RED text to the tag above:
<img
src="myimage.jpg" style="float: right;">
If you have a paragraph of text you want to wrap around the image, it is best to put the image BEFORE the text to make sure it aligns correctly. If you put the image in the middle of the text block, it will show up in the middle of the text block.
Have a question? Please leave a comment!
Please note that the double quotes in the example above are "curly quotes" instead of ambidextrous quotes. After copying the example above into your editor, you will have to replace them with normal double quotes.
ReplyDeleteSo instead of:
<img src=”myimage.jpg” style=”float: right;”>
you should be using:
<img src="myimage.jpg" style="float: right;">
To wrap text around pictures, you can get the same result with:
<img src="myimage.jpg" align="right">
While this may work, the ALIGN attribute has been deprecated and it is a coding best practice to use the inline CSS method. The problem with using deprecated tags is that they could become obsolete, and the browser won't support them anymore. At that point, you have broken code and will have to go in and correct it.
DeleteI will take your note on the quotes :) Thanks!
The W3C defines DEPRECATED as:
A deprecated element or attribute is one that has been outdated by newer constructs. Deprecated elements are defined in the reference manual in appropriate locations, but are clearly marked as deprecated. Deprecated elements may become obsolete in future versions of HTML.
User agents should continue to support deprecated elements for reasons of backward compatibility.
Definitions of elements and attributes clearly indicate which are deprecated.
This specification includes examples that illustrate how to avoid using deprecated elements. In most cases these depend on user agent support for style sheets. In general, authors should use style sheets to achieve stylistic and formatting effects rather than HTML presentational attributes. HTML presentational attributes have been deprecated when style sheet alternatives exist (see, for example, [CSS1]).