Skip to content

HTML – Part1

Posted in Tutorials

Topic 1- Divide webpage into logical sections

⁣HTML5 offers several elements that will help you organize your layout in appropriate sections:⁣⁣

  1. Header <header>
  2. Navigation bar <nav>
  3. Main Content <main> with <article> and <section> ⁣⁣
  4. Sidebar <aside>⁣⁣
  5. Footer <footer>

⁣⁣Good Webpages may look or perform differently but they share similar standard structures.⁣⁣
⁣⁣
By using this standard structure with the semantic elements mentioned above your document becomes more readable and accessible.⁣⁣

Topic 2- What are the Semantic elements? Why are they important?

Rather than writing vague divs in your document.
How about using semantic tags?

Semantic tags define the purpose of the element. It’s beneficial to use tags, class names and ids that give meaning to your content rather than just define its looks. Presentation is the responsibility of CSS.

For example- <p>,<header>,<figure> tells the content wrapped around them are paragraph, header or image. They help the browser, as well as developers, understand the meaning of their content.

Why is Semantic HTML important?

  • Helps to write clean and maintainable code
  • Enhances Accessibility
  • Improves SEO

Topic 3- Make any content on your page editable by users

The text of the webpage can be made editable using the contenteditable attribute.

Just set the contenteditable to true on any of the elements you want to make editable.
It can be helpful in the making of a simple text editor.

  Edit me!
[jsfiddle url=”https://jsfiddle.net/kkandasamy/x2hopkfr/” height=”150px” include=”html,css,js,result”]

Topic 4- Implement a Download button with HTML5

Usually, when the user clicks on a link to media files, it will be opened in the browser.
If you want to give users the option to save that file on their computer, download attribute can be used.

The download attribute to <a> elements makes the linked URL a download link rather than a navigational. Meaning users can save the link rather than navigating to it.

The download attribute can be used with or without value. To rename the default name, a value can be given which becomes the name of the file.


  Download me
[jsfiddle url="https://jsfiddle.net/kkandasamy/uc1qxaps/1/" height="150px" include="result,html,js,css"]

Topic 5- Define options with datalist tag

The Html5 <datalist> tag is used to provide autocomplete feature in the input field of the form.⁣

It specifies the set of predefined options for the user to input.⁣

To bind it to the input, it is usually used with the <input> element’s list attribute whose value matches the datalist id.⁣
⁣It works with all types of inputs like data, range, color etc.⁣

<input list="languages" placeholder="Choose language" />
<datalist id="languages">
  <option>Python</option>
  <option>Javascript</option>
  <option>Java</option>
</datalist>
[jsfiddle url=”https://jsfiddle.net/kkandasamy/c2prhqun/1/” height=”150px” include=”result,html,js,css”]

Topic 6- Collapsible Sections with HTML5⁣

⁣Details tag is used to make collapsible sections when it is required to provide extra information about a subject that users can hide or view by their choice.

Used with the summary tag which specifies the title that can be clicked to expand or collapse the details.⁣

By default, the details are hidden, the open attribute can be used to change the default behavior.⁣

<details>
<summary> Javascript </summary>
<p> I am an amazing language </p>
</details>
[jsfiddle url=”https://jsfiddle.net/kkandasamy/wtod0emr/” height=”300px” include=”result,html,js,css”]

Topic 7- Responsive Images with srcset

To make an image responsive means to switch between different versions of the image so that they are being displayed according to their respective device sizes and resolutions.⁣

⁣srcset, an attribute of <img> element is used to give URLs of different versions of the image and a descriptor so that the browser can display the most appropriate one in a given situation.⁣

Here, descriptor x represents device-pixel-ratio i.e a device with 2x resolution will only display the image associated with 2x in the srcset attribute. ⁣

The src attribute is present for browsers that don’t understand srcset.

<img srcset="pizza-small.jpg,
             pizza-medium.jpg 1.5x,
             pizza-large.jpg 2x"
     src="pizza-large.jpg"
     alt="a slice of cheesy pizza">

Topic 8- All about Quotations

Quotations are an important part of the content.⁣
There are few elements that can be used according to their semantic meanings to display quotations on your page:

The <blockquote> element:

  • Provides a section that defines quotations from another source.⁣
  • Used for indicating long quotations.⁣
  • Cite attribute is used to provide the URL of the source of the quotation.⁣

The <q> element:

  • Provides an inline quote in a block of text. ⁣
  • Used for indicating short quotations.⁣
  • Inserts quotation marks around the enclosed text.⁣

The <cite> element:

  • Provides the title of the source of work(e.g. book, album, song, poem, essay, etc.)⁣
<blockquote>
  The future was uncertain, absolutely, and there were many hurdles, twists, and turns to come, but as long as I kept moving forward, one foot in front of the other, the voices of fear and shame, the messages from those who wanted me to believe that I wasn't good enough, would be stilled.
  ― Chris Gardner,
  <cite>The Pursuit of Happyness</cite>
</blockquote>
<p>
  <q>The goal isn't to live forever, the goal is to create something that will.</q><br>
  ― Chuck Palahniuk, <cite>Diary</cite>
</p>
[jsfiddle url="https://jsfiddle.net/kkandasamy/kqgt4zr3/" height="300px" include="result,html,js,css"]

Topic 9- Highlight it!

Ever wanted to have highlighted text on your page?⁣
You can do it with just HTML, use <mark> tag to highlight parts of the text which needs extra attention.⁣

Mostly used with quotations which are from other sources to determine which text is more relevant according to you. ⁣

Don’t use it only for decoration purpose.⁣

Difference between <mark> and <strong>
<mark> denotes relevance of the content, while <strong> indicates importance.

<p>
  <q>The goal isn't to live forever, the goal is to <mark>create something</mark> that will.
  </q><br />
  ― Chuck Palahniuk, <cite>Diary</cite>
</p>
[jsfiddle url="https://jsfiddle.net/kkandasamy/ose2gkx3/" height="300px" include="result,html,js,css"]

Topic 10- Make Input fields readonly

The readonly attribute prevents the editing on an input field by the user i.e. it makes the elements immutable.⁣

These readonly elements can be styled by :read-only and :read-write pseudo classes.⁣

It is different from the disabled attribute as the elements with readonly attribute are focusable whereas this isn’t the case with the disabled.

<label for="country">Country:
</label>
<input type="text" name="country" value="India" readonly>
[jsfiddle url="https://jsfiddle.net/kkandasamy/ok913a4c/" height="300px" include="result,html,js,css"]

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *