How to use embed tag In HTML
- When embedding a pdf HTML code into a website, the embed tag isn’t used as often as the previous tags because if the user’s browser can’t handle PDF files, the display will be blank.
- The embed a pdf HTML code method is used when no fallback content needs to be provided.
Example: This example describes the embedding of a PDF file in HTML using the embed tag.
<!DOCTYPE html>
<html>
<head>
<title>PDF in HTML</title>
</head>
<style>
.pdf {
width: 100%;
aspect-ratio: 4 / 3;
}
.pdf,
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
h1,
h3 {
text-align: center;
}
h1 {
color: green;
}
</style>
<body>
<h1>w3wiki</h1>
<h3>Embedding the PDF file Using embed Tag</h3>
<embed class="pdf"
src=
"https://media.w3wiki.org/wp-content/cdn-uploads/20210101201653/PDF.pdf"
width="800" height="500">
</body>
</html>
Output:
How to Embed PDF file using HTML ?
We will learn how to embed PDF files in HTML documents, along with knowing their implementation through examples. Sometimes, you may want to insert a PDF file into an HTML document or code, to make the content more interactive. Because the formats are so different, it is not easy to accomplish the task.
These are the following methods for doing this:
Table of Content
- Using Object Tag
- Using an iframe
- Using embed tag