def set_page_type_computed_styles(page_type, html, style_for):
    """Set style for page types and pseudo-types matching ``page_type``."""
    style_for.add_page_declarations(page_type)

    # Apply style for page
    style_for.set_computed_styles(
        page_type,
        # @page inherits from the root element:
        # https://lists.w3.org/Archives/Public/www-style/2012Jan/1164.html
        root=html.etree_element, parent=html.etree_element,
        base_url=html.base_url)

    # Apply style for page pseudo-elements (margin boxes)
    for element, pseudo_type in style_for.get_cascaded_styles():
        if pseudo_type and element == page_type:
            style_for.set_computed_styles(
                element, pseudo_type=pseudo_type,
                # The pseudo-element inherits from the element.
                root=html.etree_element, parent=element,
                base_url=html.base_url)
Set style for page types and pseudo-types matching ``page_type``.
weasyprint/layout/page.py