A tag img em HTML5 - @Curso em Vídeo HTML5 e CSS3
How to Insert Images in HTML
Introduction to Image Insertion
- The lesson begins with excitement about inserting images into a website using HTML tags, emphasizing the importance of this skill.
Importance of Understanding Image Formats
- The instructor stresses that skipping lessons on image formats and sizes can hinder professional web development skills. Knowledge of where to source images and their optimal sizes is crucial for effective site construction.
Practical Exercise Preparation
- A practical exercise is introduced, encouraging students to follow along on their computers. The instructor mentions the support from Hostnet, a company specializing in website hosting and WordPress tools.
Hostnet Services Overview
- Hostnet offers services for creating websites, including tools for e-commerce and online educational platforms. They also provide marketing automation solutions.
Recap of Previous Lessons
- A recap highlights how an image was optimized from 1.8 MB to 122 KB, demonstrating the importance of managing image sizes effectively for web use.
Creating an Exercise: Step-by-Step
Setting Up the Project
- The instructor navigates through file directories to create a new exercise folder (exercise 3), preparing the workspace in Visual Studio Code.
Creating HTML Structure
- An
index.htmlfile is created with basic structure elements like<h1>for titles and paragraphs. Students are reminded about previous lessons on linking resources correctly.
Sourcing Images Online
- Instructions are given on how to find suitable images via Google Images, focusing on transparency and usage rights while searching specifically for HTML5-related graphics.
Inserting Images Using HTML Tags
Using the <img> Tag
- The process of inserting images into HTML is explained using the
<img>tag. Key attributes includesrc(source path of the image file) andalt(alternative text describing the image).
How to Optimize Image Sizes in HTML and CSS
Introduction to Image Handling
- The speaker demonstrates how to make the cursor blink in a specific area of the interface, indicating an interactive element for user engagement.
Accessibility Considerations
- Emphasizes the importance of using alternative text (alt text) for images, particularly for screen readers, enhancing accessibility for visually impaired users.
Managing Image Sizes
- Discusses checking image sizes and file dimensions within the project folder, highlighting that large images can be problematic.
- Reiterates previous lessons on resizing images effectively, suggesting a standard size of 250x200 pixels as optimal.
File Management Techniques
- Describes opening multiple files simultaneously (HTML and CSS), noting differences in spacing between elements which may require adjustments.
Resizing Images with Tools
- Introduces a cropping tool to adjust image dimensions accurately by dragging corners to fit desired specifications.
Exporting Resized Images
- Outlines steps for exporting resized images while maintaining quality settings; emphasizes consistency across both HTML and CSS files.
Supporting Content Creation
- Mentions ways viewers can support the channel through donations or subscriptions, which helps keep educational content free.
Practical Application of Changes
- Encourages viewers to replace full-size logos with optimized versions in their codebase for better performance.
Performance Benefits from Optimization
- Demonstrates how reducing file sizes significantly decreases load times; compares original vs. optimized file sizes (from 30k to 14k).
Conclusion on File Management Practices
- Highlights the efficiency gained by managing smaller image files collectively rather than relying on larger individual files.
Organizing Project Files
How to Load Images in Web Development
Loading Images from Local Directories
- The process begins with loading images from local directories, specifically mentioning the "MG" folder and how to correctly reference image files.
- A demonstration of navigating through subfolders is provided, emphasizing the importance of specifying the correct path when loading images.
- The speaker introduces external links for images, explaining that images can also be loaded from online sources without saving them locally.
Working with External Image Links
- The discussion shifts to selecting an appropriate size for external images, highlighting the need for transparency and manageable dimensions.
- Instructions are given on copying image URLs instead of downloading them, showcasing how to retrieve a direct link for use in code.
Understanding URL Structure
- An explanation of URL structure is provided, detailing how complete addresses must be used when referencing images hosted on different servers.
- The speaker notes that if the server hosting an image goes down, the image will no longer display on their site. This highlights dependency on external resources.
Key Takeaways About Image Handling
- A summary of key concepts learned about image handling is presented: choosing formats, resizing images for projects, and optimizing quality versus file size.
- Emphasis is placed on practical application; viewers are encouraged to practice these techniques at home rather than rush through learning.
Conclusion and Next Steps
- The session concludes with a recap of what was covered regarding image usage in web development and hints at future topics like favicon icons in upcoming videos.