In the last article we learned:
- Rules about using HTML headings
- Horizontal Rule in HTML
- How to Inspect webpages to view their HTML
Now let's move towards one very important flaw of HTML:
We all studied about paragraph element in previous posts which help to create a paragraph simply, but do you notice one big problem with it? Let's see with one example:
The above two code snippets have different inputs but same output. Why?
With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.The browser will remove any extra spaces and extra lines when the page is displayed.
But there is the solution.
<pre> tag is used for displaying preformatted text which means it will display output same as-as formatting in your input and will not remove extra spaces.
Although what I will you tell now, you will never use after you learn CSS. In this part we will study how you can style content in HTML using style attribute. Let's first see syntax of style attribute:
Now let's see some of the important properties you can use inside style attribute:
- background-color defines background color for that element
- color defines text color for that element
- font-family defines font used for given element
- font-size defines size of text for give element
- text-align defines alignment of given element Now let's see which values you can use for this properties.
For first two properties, you should enter any supported color as value. Modern browsers support 140 named colors. You can see them at http://htmlcolorcodes.com/ . For font-family you should enter any valid fonts supported by browsers.For font-size , you can enter size in percentage(%) or pixels(px). For text-align, alignment can be _ left, right or center _.
Let's finally one example combining all above concepts:
That's all for this article. I hope you all are practising what you are learning here because Practise is key to success. In the next part, we will learn about some other ways beside <style> tag to enhance your content. Comment on how you think this article is, what improvements should I do and for any doubts. Share with your friends and _ keep coding _.