In the last article we learned:
Now let's move towards one very important flaw of HTML:- Rules about using HTML headings
- Horizontal Rule in HTML
- How to Inspect webpages to view their 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.
HTML <pre> Tag
<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.
HTML Style Attribute
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:
Property Use
Now let's see some of the important properties you can use inside style attribute:
Property Use
- 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
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.
Comments
Post a Comment