LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML-CSS-PHP-JavaScript / PHP Codes » How To Validate/Identify Deprecated HTML Tags In A WebPage Using PHP?

How To Validate/Identify Deprecated HTML Tags In A WebPage Using PHP?

How-To-Validate-Identify-Deprecated-HTML-Tags-In-A-WebPage-Using-PHP
Deprecated tags and attributes are those which have been replaced by other, newer, HTML constructs. They are still included in the HTML draft or recommendation but are clearly marked as deprecated. Once deprecated, tags may well become obsolete. The draft “strongly urges” the nonuse of deprecated tags.

A complete list of deprecated HTML tags and attributes are given here. All the tags have been ordered alphabetically along with their equivalent tag or alternate CSS option.

TagDescriptionAlternate
<applet>Deprecated. Specifies an applet<object>
<basefont>Deprecated. Specifies a base font
<center>Deprecated. Specifies centered texttext-align
<dir>Deprecated. Specifies a directory list
<embed>Deprecated. Embeds an application in a document<object>
<font>Deprecated. Specifies text font, size, and colorfont-family, font-size
<isindex>Deprecated. Specifies a single-line input field
<listing>Deprecated. Specifies listing of items<pre>
<menu>Deprecated. Specifies a menu list
<plaintext>Deprecated. Specifies plaintext<pre>
<s>Deprecated. Specifies strikethrough texttext-decoration
<strike>Deprecated. Specifies strikethrough texttext-decoration
<u>Deprecated. Specifies underlined texttext-decoration
<xmp>Deprecated. Specifies preformatted text<pre>

To check your website online, you can use https://seositecheckup.com/tools/deprecated-html-tags-test checker.

Table of Contents

Why Do HTML Elements/Tags Get Deprecated?

Over the years, our way of thinking about HTML has evolved. Originally, it was an all-purpose markup language for displaying and styling content online. Over time, as external stylesheets became more of a thing, it began to make more sense to think about web development differently — as a separation of concerns where HTML defines the content of a page, and CSS handles the presentation of it.

This separation of style and content brings numerous benefits:

  • Avoiding duplication
  • Ease of management
  • Readability
  • Caching
  • Developer specialization
  • User options
  • Responsiveness and device independence

There are many code snippets available online or on many other blogs and website but everyone is not able to optimize your blog or website so you need some optimized code snippet. So now checkout out code snippet for your blog and website that will give you all features for your desired code. Now grab the ready to use code and paste it where you want.

How To Parse A Remote URL WebPage To Extract Desired Content Using PHP?

The below snipper with return a PHP variable is $webPageContent that is a plain string variable. Then we will instantiate the DOMDocument Class.

<?php
$webPageURL = "https://www.google.com";

/****************************************************************************/
// Garb The WebPage Content
/****************************************************************************/
$ch = curl_init();
$timeout = 5; //5 is seconds
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
curl_setopt($ch, CURLOPT_URL, $webPageURL);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_HEADER, 1);
$webPageContent= curl_exec($ch);
curl_close($ch);


/****************************************************************************/
// Parse The HTML Content
/****************************************************************************/
//Instantiate The DOMDocument Class
$htmlDom = new DOMDocument;
$htmlDom->validateOnParse = true;

//Parse the HTML of the page using DOMDocument::loadHTML In UTF8 Encoding
//@$htmlDom->loadHTML($webPageContent);
@$htmlDom->loadHTML(mb_convert_encoding($webPageContent, 'HTML-ENTITIES', 'UTF-8'));

/****************************************************************************/
// HTML - Deprecated Tags https://www.tutorialspoint.com/html/html_deprecated_tags.htm
/****************************************************************************/
$deprecatedTAGs = ["applet","basefont","center","dir","embed","font","isindex","listing","menu","plaintext","s","strike","u","xmp"];
$isDeprecated = "true";
foreach($deprecatedTAGs as $deprecatedTAG){
if(count($htmlDom->getElementsByTagName($deprecatedTAG)) > 0){
$isDeprecated = "false";
break;
} else {
$isDeprecated = "true";
}
}

Customization:

You can add more Deprecated tags in the upper array list so it will find out those too.

Recommended For You:
TextArea :A Best HTML Tag To Write Something Online.

Troubleshooting the Errors

Do it with concentration and patience. Check your alls steps and again and all codes or scripts. If you find any error you can contact us anytime via comment or better via email, We are always here to help you.

Final Words:

That’s all we have. We hope that you liked this article. If you have any problem with this code in your template then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us or If you have any doubts and problem please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave your precious feedback in our comment form below. Happy development, See you in the next article.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *