Displaying Images in HTML
Displaying Images in HTML
<!
DOCTYPE
html>
<html>
<head>
<meta charset="utf-8">
<title>Displaying Images</title>
</head>
<body>
<h1>
Don't be afraid to be <then a 100% success:
</h1>
<p>
<img src="picture-with-quote.jpg"
width="400"
height="235"
alt="Picture of Theodore Roosevelt">
"It is not the critic who counts; not the
man who points out how the strong man stumbles,
or where the doer of deeds could have done them
better. The credit belongs to the man who is
actually in the arena, whose face is marred by
dust and sweat and blood; who strives valiantly;
who errs, who comes short again and again,
because there is no effort without error and
shortcoming; but who does actually strive to do
the deeds; who knows great enthusiasms, the great
devotions; who spends himself in a worthy cause;
who at the best knows in the end the triumph of
high achievement, and who at the worst, if he
fails, at least fails while daring greatly, so
that his place shall never be with those cold and
timid souls who neither know victory nor
defeat."
</p>
<p>
<img
src="http://lorempixel.com/output/nature-q-c-640-480-
1.jpg"
width="640"
height="480">
</p>
<p>Theodore Roosevelt 1910 © Copyright</p>
</body>
</html>
Displaying Images in HTML
This article is part of the Beginner Web Developer Series. The series
is targeted to people who’d like to start serious web development, as
well as people who are already web developers and want to solidify
their knowledge of fundamentals while possibly filling in some holes. If
you find yourself tinkering with HTML, CSS, or Javascript until you
sort of get it to work, this series is for you. The material in this series
is closely tied to my top-rated Coursera course.
Perhaps nothing enhances a website better than
strategically placed images.
Read on.
It’s very often the case that you use images as visual
anchors in the layout of your page. In other words, the
layout of your page relies on the image being a certain
size.
For example, your design may dictate that the top 200
pixels are taken up by some header image, followed by
some text below the image.
The browser will read the header image tag and start
loading the image, pointed to by the src attribute.
However, the browser does not wait for the image to
load before it continues to read and render the rest of
the HTML code. The image loading happens in parallel
as the browser proceeds to interpret and render the rest
of the HTML onto the screen.
Usually, images take longer to download than the text-
based HTML code. Therefore, the browser will be ready
to display the text that was supposed to follow the
header image before the header image is downloaded
and displayed.
However, without the fully downloaded image file, there
is no way to find out its size, i.e., the width and height.
The browser will not allocate any space for the image.
To the user, the visual affect will be that the text, which
was supposed to appear below the image, will appear at
the top at first, then jump down as the image is shown.
Bingo! 😀
Summary
Let’s give a quick summary of what we’ve covered in
this article: