Skip to main content

WDS4 - HTML Attributes and Some Important Rules

In the last article we learned:
  • HTML Headings
  • Paragraphs
  • Links
  • Images
Now we are 3 rules that we should always follow:
  1. Although HTML tags are not case sensitive which means you can use either <p> or <P> for paragraph tags, you should always use lowercase tags as many standards use same in their documentation and you will form a good habit.
  2. You should never forget end tag in HTML. In some cases, the document will be displayed perfectly without using end tag but consider it as just a coincidence. In many cases, it will produce wrong or undesirable output.
  3. In last class when we learned about attributes which consist of name and value pair, always use them as name="value". Although quotes(") are not necessary, it is a good habit to use them.You can use both single or double quotes but double quotes are preferable. You have to use single quotes when value itself contains double quotes.
Two important notes:
  1. You can use HTML tags in nested form(in fact you are already using it). In all the examples we are writing all our document inside <html> and </html> tags that means our all other tags are nested in between this tags. Similarly, you can use heading tag inside paragraph tag to create heading inside the paragraph.  
  2. There are some elements which do not require any content. HTML elements with no content are called empty elements.<br> is an empty element without a closing tag (the <br> tag defines a line break).Empty elements can be "closed" in the opening tag like this: <br />. HTML5 does not require you to close empty elements.

HTML Attributes

In last tutorial(WDS3), while learning HTML links and image tags we studied a new concept called attributes. Now let's study them in detail:
  • Attributes provide more control/ information about elements.
  • Attributes are always specified in the starting tag of tags pair.
  • For name and value pair of attributes, attributes are written as name="value".
Now let's see some attributes and their uses: 
  • href - HTML links are defined with the <a> tag. The link address is specified in the href attribute. We have done an example in WDS3.
  • src - Used in <img> tag for displaying image. It represents the source of an image.
  • width and height - To represent width and height of an image.
  • alt - Represents alternative text used when an image is not displayed.
  • title -  This attribute is used in paragraph element inside <p> tag. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph.  
That's all for this article. In the next part, we will learn about attributes used in HTML.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

Popular posts from this blog

Python Project - 1 (Password Locker)

Hello reader, this is my first post on this blog. I created this blog for various purposes including First and most importantly improve my coding Help others to learn various concepts in programming  To complete my hobby of blogging So, I am starting various series simultaneously, hope I will able to continue them. In this " Python Project " series, I will create simple python projects and will give step by step procedure to do that. I think you should first try to complete code yourself, then if you get stuck anywhere, feel free to check steps, refer complete code or comment for more help. Let's begin... Idea and Need: You probably have accounts on many different websites. It is a bad habit to have the same password and it is difficult to remember all passwords. So it is a good idea to use "Password Manager Software". So why not create it yourself? So let's see what steps you should follow... Steps: We have to create a menu which has the...

WDS15 - Handle your Metadata

In the last short article we learned about: HTML iframe element to display webpage inside webpage Now in this article, we are going to see something which will not make the direct impact on how you are seeing your webpage but will do a lot of background work. So let's get started... In the very first article on HTML, while learning basic HTML page structure we divided HTML document into two main parts: head and body. This head contains metadata about HTML document which we write in the body of HTML. Ler's see how to write this metadata... HTML <meta> element <meta> element is used to specify about author of webpage, various tags for article, page description and many other things. Metadata is used by browsers to decide how to display content and search engines to classify web pages according to tags and keywords. HTML Character set A defined list of characters recognized by the computer hardware and software. Each character is represented by a num...

WDS5 - Inspect HTML and Other Tags

In the last article we learned: 3 Important HTML Rules Nested and empty elements HTML Attributes   Let's start today with some important points: HTML Headings  We have already seen HTML headings represented by tags <h1> to <h6> where <h1> is most important heading while <h6> is least important heading. Now I am mentioning some important points which you should follow when using HTML headings: Search engines use the headings to index the structure and content of your web pages. This is important because you should always follow an order of heading tags. <h1> should be used for main heading, <h2> for less important subheadings and so on. In fact, it is commonly followed a system of using only one <h1> tag in the document to represent heading of your document and nowhere else. Heading tags should only be used for headings and not for making text bigger or bold. Different tags are used for this operations and we will ...