diff --git a/IPython/core/display.py b/IPython/core/display.py
index ca5c3aa5b..4a2e28179 100644
--- a/IPython/core/display.py
+++ b/IPython/core/display.py
@@ -666,6 +666,11 @@ def _repr_pretty_(self, pp, cycle):
 
 class HTML(TextDisplayObject):
 
+    def __init__(self, data=None, url=None, filename=None, metadata=None):
+        if data and "<iframe " in data and "</iframe>" in data:
+            warnings.warn("Consider using IPython.display.IFrame instead")
+        super(HTML, self).__init__(data=data, url=url, filename=filename, metadata=metadata)
+
     def _repr_html_(self):
         return self._data_and_metadata()
 

HTML vs Iframe
I was again the witness of people miss-using HTML to display IFrames, and having issues. 

Could we detect in  HTML the usage of `<iframe>....</iframe>` and warn user that there is an iframe object ? 

diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py
index 3851d6757..7c1f978b4 100644
--- a/IPython/core/tests/test_display.py
+++ b/IPython/core/tests/test_display.py
@@ -195,6 +195,14 @@ def test_displayobject_repr():
     j._show_mem_addr = False
     nt.assert_equal(repr(j), '<IPython.core.display.Javascript object>')
 
+@mock.patch('warnings.warn')
+def test_encourage_iframe_over_html(m_warn):
+    display.HTML('<br />')
+    m_warn.assert_not_called()
+
+    display.HTML('<iframe src="http://a.com"></iframe>')
+    m_warn.assert_called_with('Consider using IPython.display.IFrame instead')
+
 def test_progress():
     p = display.ProgressBar(10)
     nt.assert_in('0/10',repr(p))

pip install -e .[test]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y graphviz
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==25.3.0
backcall==0.2.0
certifi==2025.1.31
charset-normalizer==3.4.1
coverage==7.8.0
decorator==5.2.1
exceptiongroup==1.2.2
execnet==2.1.1
fastjsonschema==2.21.1
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
ipykernel==5.5.6
-e git+https://github.com/ipython/ipython.git@194d1d7fe2fcc8547205bd7f54fcf63bee9df4e3#egg=ipython
ipython-genutils==0.2.0
jedi==0.19.2
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter_client==8.6.3
jupyter_core==5.7.2
nbformat==5.10.4
nose==1.3.7
numpy==2.0.2
packaging==24.2
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
platformdirs==4.3.7
pluggy==1.5.0
prompt-toolkit==2.0.10
ptyprocess==0.7.0
Pygments==2.19.1
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
rpds-py==0.24.0
simplegeneric==0.8.1
six==1.17.0
testpath==0.6.0
tomli==2.2.1
tornado==6.4.2
traitlets==5.14.3
typing_extensions==4.13.0
urllib3==2.3.0
wcwidth==0.2.13
zipp==3.21.0

name: ipython
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==25.3.0
      - backcall==0.2.0
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - coverage==7.8.0
      - decorator==5.2.1
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - fastjsonschema==2.21.1
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - ipykernel==5.5.6
      - ipython-genutils==0.2.0
      - jedi==0.19.2
      - jsonschema==4.23.0
      - jsonschema-specifications==2024.10.1
      - jupyter-client==8.6.3
      - jupyter-core==5.7.2
      - nbformat==5.10.4
      - nose==1.3.7
      - numpy==2.0.2
      - packaging==24.2
      - parso==0.8.4
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - prompt-toolkit==2.0.10
      - ptyprocess==0.7.0
      - pygments==2.19.1
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-xdist==3.6.1
      - python-dateutil==2.9.0.post0
      - pyzmq==26.3.0
      - referencing==0.36.2
      - requests==2.32.3
      - rpds-py==0.24.0
      - simplegeneric==0.8.1
      - six==1.17.0
      - testpath==0.6.0
      - tomli==2.2.1
      - tornado==6.4.2
      - traitlets==5.14.3
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - wcwidth==0.2.13
      - zipp==3.21.0
prefix: /opt/conda/envs/ipython

IPython/core/tests/test_display.py::test_encourage_iframe_over_html
IPython/core/tests/test_display.py::test_image_mimes IPython/core/tests/test_display.py::test_display_available IPython/core/tests/test_display.py::test_display_id IPython/core/tests/test_display.py::test_update_display IPython/core/tests/test_display.py::test_display_handle
IPython/core/tests/test_display.py::test_image_size IPython/core/tests/test_display.py::test_geojson IPython/core/tests/test_display.py::test_retina_png IPython/core/tests/test_display.py::test_retina_jpeg IPython/core/tests/test_display.py::test_base64image IPython/core/tests/test_display.py::test_image_filename_defaults IPython/core/tests/test_display.py::test_textdisplayobj_pretty_repr IPython/core/tests/test_display.py::test_displayobject_repr IPython/core/tests/test_display.py::test_progress IPython/core/tests/test_display.py::test_progress_iter IPython/core/tests/test_display.py::test_json IPython/core/tests/test_display.py::test_video_embedding IPython/core/tests/test_display.py::test_html_metadata
IPython/core/display.py
IPython/core/display.py