Html frames allows you to divide a web page into a set of frames, where each html frame is capable of displaying one embedded web page. You may have noticed pages with frames after applying code for frames in html that allow you to visit a third party page while leaving the header and navigation of the original site intact.
|Html Frames Examples and Code|
These days html frames are, for the most part, considered “old school” because they cause navigation and usability problems, and they are not recommended by the W3C. However you will still find them in use in some situations.so below are some codes for frame in html.
To create set of html frames in a page, use the <frameset> and <frame> elements.
Html Frames example
<frameset rows=”30%, *, 20%”>
<frame name=”header” src=”header.html” />
<frame name=”content” src=”content.html” />
<frame name=”footer” src=”footer.html” />
In above html frames code:-
Creates a set of frames as three rows, where the first frames takes up 30% of the browser, the last part takes up 20% and the middle part takes up the remaining space.with respect to above applied html frames example.
You can also specify framesets as columns of frames or as rows and columns.
For each frames we use a <frame> element , each frames specifies a name for the frame and the source HTML file that goes in the frame. in the above code for frame in html
You can also target individual names with your <a> elements by specifying the frame’s name in the target of the link, like this:
<a href=”newpage.html” target=”content”> New content </a> in the above code for frame in html
There is also a related element called as <iframe> that is widely supported in newer browser . the inline element <iframe> allows you to place a frame anywhere within a page.Here is how.
You use <iframe>
<iframe name=”inlinecontent” src=”newcontent.html” width=”500” height=”200” />
Finally you should know that to use html frames you will need to use a DOCTYPE in the page that contains the frameset. The frameset DOCTYPE are considered to be transitional, so you cannot have frames and be strict,
For HTML 4.01 use
<!DOCTYPE html PUBLIC “-//w3c//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>
And for XHTML 1.0 use:
<!DOCTYPE html PUBLIC “-//w3c//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml11/DTD/XHTML11-frameset.dtd