Instructions:Must Read¶
While developing web pages using html, a top down approach is followed where the first html tag will be for the top most portion of the web page, then the next tag on the next line of the html file wil be for defining how the portion just below the top most portion looks and so on. So we start of at the top left corner of our browser and then go down to as long as we want, as the browser allows for scrolling.In other words, while writing html files, we don’t have to worry about how the top most left portion looks, then the top most central portion, then the top most right portion and so on. Instead when we start of with <h1> tag, heading text appears at the top of our web page and then when we add a <p> tag in the next line,text in the <p> tag appears as a pargraph(wrapped to the size of browser window) just below our heading. py4html follows the exact same approach by calling one function for what we want at topmost in first line followed by the function call for what we want below that in the next line and so on.
Function calls, Lists and Dictionaries¶
In absolutel short words, py4html is just about these three things. We call the respective functions for whatever equivalent html tag we need and then as arguments if and when needed, we pass either a list or a dictionary or sometimes both.
For eg, the function call
biggest_heading(“Sreehari P V”) with the string “Sreehari P V” passed as argument is sufficient to produce a h1 heading with the text “Sreehari P V” at the top of the page. This function call will be converted to the following html code in the equivalent html file generated by py4html h1(“Sreehari P V”)
We can also pass arguments to this function to modify the appearance of h1 heading. We can pass text_type argument either as the next positional argument separated by comma or we can pass it as the keyword argument text_type=”bold” . This argument is used to change the heading to bold itlallics and so on. We can also pass the id =”” and class_name=””” to assign either id or class_name to the heading tag respectively for later changing its style or applying javascript.