Attributes

In HTML, attributes are used to provide additional information about HTML elements. There are two main types of attributes:

Element-Specific Attributes

These attributes are specific to certain elements. You can’t use them on just any tag — only where they are allowed.


Attribute Element Description
href <a> Specifies the link URL
src <img> Specifies the source of an image
alt <img> Provides alternate text for an image

Global Attributes

These attributes can be used on any HTML element. They are shared across all tags.


Attribute Symbol Description
id # Specifies a unique ID for the element
class . Assigns one or more class names for styling or JS

The different Between Id and class


If you use the same id on multiple elements, the HTML is invalid and may lead to unexpected behavior.

HTML Entities

HTML entities are special codes used in HTML to display characters that are reserved in HTML or not available on a keyboard.

Result Name
< &lt;
> &gt;
© &copy;

Semantic Elements

Semantic elements are HTML tags that clearly describe their meaning — both to the browser and to developers. They improve readability, accessibility, and SEO.

Note: Block Element

Tags
<header></header>
<main></main>
<footer></footer>
<aside></aside>
<nav></nav>
<section></section>
<article></article>
<summary></summary>
Semantic

They tell you what the element is for, rather than how it looks. This improves:

Audio & Video

Audio

<audio></audio>

Two different way to type

  • <audio controls src="Audio1.mp3" type="audio/mpeg"></audio>
  • <audio controls>
    <source src="Audio1.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>

Properties :

  • inline-block
  • Opening and Closing Tag
  • controls : displays the audio player
  • src : allows you to specify the audio file and its type.
  • type : Helps the browser decide whether it can play the file before downloading it.

Video

<video></viedo>

Two different way to type

  • <video controls src="Video1.mp4" type="video/mp4" width="500" poster="poster.jpg"></video>
  • <video width="400" controls>
    <source src="video.mp4" type="video/mp4">
    Your browser does not support the video tag.
    </video>

Properties :

  • inline-block
  • Opening and Closing Tag
  • controls : displays the audio player
  • src : allows you to specify the video file and its type.
  • type : Helps the browser decide whether it can play the file before downloading it.
  • width : Sets the width of the video player in pixels.
  • poster : Defines an image to show before the video plays.

Comparison between Inline , Block and Inline Block


display Starts on New Line? Can Set Width/Height? Behaves Like Common Example
inline No No Like text <span>, <a></a>
block Yes Yes Like a box <div>, <p></p>
inline-block No Yes Mix of both <img> <button> </button>

Naming Conventions

General Best Practices:

  • HTML is not case-sensitive
  • Use lowercase
  • Use hyphens - for multi-word names
  • Avoid spaces and special characters
  • Be semantic and descriptive

Avoid:

  • Special characters: @, $, #, %, etc.
  • Starting names with numbers: 1header

Assignment

Write a code of a real website as a blog which contains a header and nav links, two sections each one includes 3 articles, don't forget the aside and finally the footer including copyright symbol

Add audio & Video