Have you ever seen a relatable content such as a video or a useful web application that you thought could be useful for your website? Maybe you’ve encountered a nifty website that had something you wanted to share. Something you can flourish while staying inside legal, ethical boundaries of content copyrights? Times like these are when iframes come to use.
In layman terms, Iframe( short for Inline Frames) is basically a separate window inside your webpage that shows a separate webpage. This lets you directly show the content of any website by directly accessing its source directly. Since Iframes implement the ‘Cross-Platform Domain Policy’, using data from a different website is completely safe. Furthermore, this lets the source owner as well as the site owner to track the views and web analytics individually.
What do iframes do?
Iframes open a world of endless possibility and creativity in webpage designing. Thus, we don’t need to re-upload the element since the webpage is loaded directly from the source itself.
The iframe loads independently from the rest of the components which makes the webpage more stable as even if the iframe itself breaks, the side can function normally. Additionally, we can code the iframe in a manner that fits the outlook of our website.
A lot of websites use Iframes to share multimedia content. Almost every third-party content-based website allows you to embed their multimedia element using iframes. We can easily preview Web applications, Videos, Audio, images, web analytics etc separately in this manner.
Most ads also heavily feature the use of Iframes as well. Since iframes follow the cross-domain support system, it is easier for the advertisers to track the number of views of their ads and work accordingly.
One cannot modify Iframe’s own webpage or HTML document. Therefore, it keeps the source element intact and secure as well.
Moreover, the number of iframes can be inserted in a single webpage. One can change the appearance of the window itself as well. So, in that sense, we can insert multiple iframes or Ads in a single webpage without deterring the performance and speed of the website itself.
How to Use WordPress iFrame
WordPress Iframes are relatively easy to use. There are two different ways of inserting iframes into your website. We have individually explained these methods below:
Traditionally we can use Iframes by directly using the HTML Code and its parameters.
This requires some level of understanding of HTML but in basic terms, we use the code:
Here you insert the URL source of the content you want to share inside the inverted commas. Next, we use the available tags for formatting the size of your window. The most popularly used ones are:
- Width/Height – These attributes define the size of your window. The size given is defined in Pixels.
- Scrolling – This attribute specifies whether or not to allow Scrolling inside the Iframe. This can be set to : Yes/No/Auto
- Frameborder – Frameborder can be used to choose whether or not to display borders for the Iframe. This can be set to either ‘0’ or ‘1’
- Align – The align attribute defines the alignment of your iframe. The possible values for this attributes are: Left/Middle/Right/Top/Bottom
For any other tags, refer to here.
So, using these attributes you can define the appearance of your iframe. So, for example, we can use:
Now, we insert this into the text editor
By doing this, we get an output that looks like :
Thus, by using the URL of an element, website or webpage we can build our own iFrame.
Using Embed Links:
Most third-party content websites allow you to share their content by embedding their content. To that extent, most of them allow users to copy a pre-built IFrame code and copy it into the Text editor of WordPress.
Embedding becomes much easier in this fashion and almost any beginner can use this method easily.
The basic process for this is identical to almost every popular content based website. For an example, lets use a Youtube video as it is one of the most popular form of Embedded content. We will be taking the following video and embedding it onto a page:
If you want to create an uncustomized iframe, pasting the URL directly to the visual editor builds an iframe automatically.
But if you want to build a customized window, set to your own preferences you can either use the HTML editor and code the parameters to get the desired output.
For example, we can use the above attributes to get:
<iframe src=”https://www.youtube.com/watch?v=pZEQEQB-qXw” frameborder=”0″ height=”500px” width=”500px” scrolling=”auto” align=”right” name=”ASDASDSAD>
Alternatively, you can directly receive the embed Iframe code of any youtube video. For, this just open the required video on youtube. Then, Click on the share button that is below the video window and then click on Embed.
This shows you the Embed code for the video which you can copy. You can further change the embed window’s options to suit your website.
So we get,
Using this method lets you turn on/off some of the embedding features youtube allows such as Player controls, suggested video lists and privacy mode
Then, insert this code into the Text editor.
Now, the webpage should display the referenced HTML document.
Almost every popular website allows you to share their content in a similar fashion and all of them feature a handy share button in their posts.
Now that you’re aware of how iFrames work and how to embed them you can share content on the go without any issues. But a huge word of caution:
ALWAYS make sure that the website you take the iFrame code is trustable and secure. Hackers can hide a malicious iframe code snippet onto either the embed code or the source element itself. This lets them track information of your viewers, and install malware, ad-wares, and other such notorious elements into their PC. So we cannot stress the need for checking the iFrame code to make sure there’s not a suspicious URL such as a PHP code. You can read more on this here.
So stay safe and keep your website’s reputation high and make sure your site visitors don’t feel troubled by using your website. To learn more about improving your WordPress site, read these articles:
- Removing Powered By WordPress footer link.
- How to clear WordPress cache
- Adding Rich Snippets to WordPress