HTML - attributes - srcdoc

revision:


Content

"srcdoc" attribute : specifies content to be shwon in iframe syntax some examples


"srcdoc" attribute : specifies content to be shwon in iframe

top

The srcdoc attribute specifies the HTML content of the page to show in the inline frame. This attribute is expected to be used together with the "sandbox" and "seamless" attributes.
If a browser supports the "srcdoc" attribute, it will override the content specified in the src attribute (if present). If a browser does NOT support the "srcdoc" attribute, it will show the file specified in the src attribute instead (if present).

The srcdoc attribute can be used on the following element: <iframe>.


syntax

top

<iframe srcdoc="HTML_code"></iframe>

HTML_code: the HTML content to show in the iframe. Must be valid HTML syntax.


some examples

top

Your browser does not support iframes.

codes:

                    <iframe style="margin-left:3vw;" srcdoc="Hello from srcdoc!" src="https://www.lwitters.com/">
                    </iframe>
                    <p class="spec">Your browser does not support iframes.</p>
                

codes:

                    <iframe style="margin-left:3vw;" srcdoc = "<h3>Learning web development</h3>" src = 
                    "lwitters.com/coding.php">
                        <p class=spec">Browser does not support iframes.</p>
                    </iframe>