HTML Paragraphs Overview
We already had an introduction about HTML Paragraphs. This lesson will just give us an overview of paragraphs and we'll get a little bit more into details about how paragraphs work.
A paragraph element is defined as follows;
<p>content</p>
HTML Paragraph Exercises;
Imagine the following scenario
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pharetra urna nec porta porttitor. Integer
lobortis mattis iaculis. Suspendisse nec fringilla ex. Curabitur urna erat, ullamcorper non nisl ac, varius egestas
tortor. Donec in orci
sapien. Proin interdum libero risus, nec ornare eros mattis nec. Quisque sed tristique est, nec molestie
diam. Fusce in velit vel turpis faucibus accumsan nec non neque. Curabitur ac consequat diam. Donec et mauris
quis est lobortis feugiat
quis nec leo. Integer vulputate, mauris molestie lobortis posuere, augue nunc vestibulum mauris, nec
vehicula quam enim nec mi. Pellentesque pretium volutpat dolor nec tempus. Proin imperdiet velit ut nisl
egestas egestas. Fusce at lorem efficitur,
eleifend diam et, maximus libero. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
The content will not be displayed in the same order as we have it outlined above in code. To be able to display it like that, we'd need to use line break element or <br>. Also please note that even if you place a lot of spaces between the words the web browser will still remove these extra spaces automatically.

HTML Elements - Nested elements
Another thing to keep in mind is nesting of elements like in the example.
<p><img src="http://website.com/assets/images/image-1400x933-23.jpg" alt="website.com" width="204"
height="142">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pharetra urna nec porta porttitor. Integer
<br>lobortis mattis iaculis. Suspendisse nec fringilla ex. Curabitur urna erat, ullamcorper non nisl ac, varius egestas tortor. Donec in orci
<br> sapien. Proin interdum libero risus, nec ornare eros mattis nec. Quisque sed tristique est, nec molestie diam. Fusce in velit vel turpis
faucibus accumsan nec non neque. Curabitur ac consequat diam. Donec et mauris quis est lobortis feugiat
<br> quis nec leo. Integer vulputate, mauris molestie lobortis posuere, augue nunc vestibulum mauris, nec <br>vehicula quam enim nec
mi. Pellentesque pretium volutpat dolor nec tempus. Proin imperdiet velit ut nisl <br>egestas egestas. Fusce
at lorem efficitur,<br> eleifend diam et, maximus libero. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
If you notice here we have a main element paragraph <p> then we have embedded the image <img> element then the line break <br> element. This is a powerful feature and later on we'll be taking advantage of it.

Pre-defined content <pre>
Imagine that we have a paragraph as follows.
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pharetra urna
nec porta porttitor. Integer lobortis mattis iaculis. Suspendisse nec fringilla ex.
Curabitur urna erat, ullamcorper non nisl ac, varius egestas tortor. Donec in orci</p>
Take a look at the many spaces that we have kept between the words of the content. If we run it as a paragraph then the web browser will eliminate the extra spaces and will keep only one space between the words.
If we want to keep the extra spacing in the subject format then we'd need to use another HTML element or the <pre> element.
Example" ><pre>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pharetra urna
nec porta porttitor. Integer lobortis mattis iaculis. Suspendisse nec fringilla ex.
Curabitur urna erat, ullamcorper non nisl ac, varius egestas tortor. Donec in orci</pre>

Take a look at this point. We have kept the extra spacing and format of the text by using the <pre> element. You can run the HTML Paragraphs.html file for that purpose
Comments
Post a Comment