Saturday, January 11, 2025
HomeProgrammingHow to Add your Own Picture on html? - css

How to Add your Own Picture on html? – css

To add your own picture (image) using HTML and CSS, follow these steps:

1. Prepare Your Image

First, make sure you have the image file (like myimage.jpg or myimage.png) saved in a directory accessible from your HTML file.

2. HTML Markup

Use the <img> tag in your HTML to insert the image.

html Copy code

<!DOCTYPE html>

<html lang=”en”>

<head>

<meta charset=”UTF-8″>

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

<title>My Image</title>

<link rel=”stylesheet” href=”styles.css”>

</head>

<body>

See also  Virtual Function in Java

<div class=”container”>

<img src=”path/to/your/image.jpg” alt=”Description of your image”>

</div>

</body>

</html>

3. CSS Styling (Optional)

You can use CSS to style the image or its container as needed. Here’s an example of a simple styling:

css Copy code

.container { text-align: center; /* Centers the image horizontally */

margin-top: 20px; /* Adds space above the image */}

.container img {width: 300px; /* Sets the width of the image */

height: auto; /* Maintains aspect ratio */

See also  Java Database Connectivity (JDBC) in 5 Steps

border-radius: 10px; /* Adds rounded corners to the image */

box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Adds a subtle shadow */}

Explanation:

<img> Tag: The src attribute specifies the path to your image file (“path/to/your/image.jpg”). The alt attribute provides alternative text for accessibility.

CSS Styling: Use CSS to adjust the appearance of the image or its container, such as size (width and height), alignment (text-align), margins (margin-top), and visual effects like shadows (box-shadow) or rounded corners (border-radius).

See also  Difference between DELETE and TRUNCATE

Make sure to replace “path/to/your/image.jpg” with the actual path to your image file on your server or local directory.

This setup will display your image on a web page styled according to your CSS rules.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Who is Dolly Parton?

DBMS Examples

2001 in Roman Numerals

Recent Comments

0
Would love your thoughts, please comment.x
()
x