Intro to HTML

Last updated: July 30th, 20202020-07-30Project preview
In [1]:
%%HTML
<p>hello world</p>

hello world

In [2]:
%%writefile foo.html
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Team X</title>
</head>

<body>
  <h1>Team X</h1>
  <p>We are Team X.</p>
  <ul>
    <li>Art</li>
    <li><a href="http://www.thesimpsons.com/">Bart</a></li>
    <li>Cara</li>
  </ul>
</body>

</html>
Overwriting foo.html
In [3]:
%%js

alert("hello")
window.open('foo.html');
In [4]:
%%HTML
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Team X</title>
 
<style>
    h1 {
  color: teal;
  font-family: Georgia, serif;
  font-size: 200%;
}

p { 
  color: blue;
}

ul {
  padding-left: 100px;
  list-style-type: circle;
}

li {
  color: rgb(18,52,86); 
}
</style>

</head>

<body>
  <h1>Team X</h1>
  <p>We are Team X.</p>
  <ul>
    <li>Art</li>
    <li><a href="http://www.thesimpsons.com/">Bart</a></li>
    <li>Cara</li>
  </ul>
</body>

</html>
Team X

Team X

We are Team X.

In [30]:
h1 {
  color: teal;
  font-family: Georgia, serif;
  font-size: 200%;
}

p { 
  color: blue;
}

ul {
  padding-left: 100px;
  list-style-type: circle;
}

li {
  color: rgb(18,52,86); 
}
  File "<ipython-input-30-93722c729ee0>", line 1
    h1 {
       ^
SyntaxError: invalid syntax
In [6]:
import webbrowser

# generate a URL
url = 'https://www.google.com'
webbrowser.open(url)
Out[6]:
False
In [7]:
%pycat foo.html
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Team X</title>
</head>

<body>
  <h1>Team X</h1>
  <p>We are Team X.</p>
  <ul>
    <li>Art</li>
    <li><a href="http://www.thesimpsons.com/">Bart</a></li>
    <li>Cara</li>
  </ul>
</body>

</html>
In [6]:
from IPython.display import Javascript

def window_open(url):
    display(Javascript('window.open("{url}");'.format(url=url)))
    
window_open('foo.html')
In [4]:
import IPython
url = "https://staffwww.dcs.shef.ac.uk/people/S.Maddock/index.shtml"
iframe = '<iframe src=' + url + ' width=700 height=350></iframe>'
IPython.display.HTML(iframe)
Out[4]:
In [41]:
import webbrowser
webbrowser.open("https://www.google.co.uk")
Out[41]:
False
In [31]:
import webbrowser
webbrowser.get().name
Out[31]:
'/content/chrome.exe'
In [42]:
import webbrowser
webbrowser.open("https://i.notebooks.ai/i/GbtaKl")
Out[42]:
False
In [3]:
import IPython
url = "https://codepen.io/stevemaddock/pen/YozmVE"
iframe = '<iframe src=' + url + ' width=700 height=350></iframe>'
IPython.display.HTML(iframe)
Out[3]:
In [8]:
from IPython.display import Javascript

def window_open(url):
    display(Javascript('window.open("{url}");'.format(url=url)))
    
window_open('https://codepen.io/stevemaddock/pen/YozmVE')
In [ ]:
 
Notebooks AI
Notebooks AI Profile20060