Beyond ABAPdesigned by@Tejoram97
Beyond ABAP / SAPUI5 / HTML5 & CSS3

HTML5 & CSS3

SAPUI5 · SAP Fiori UI5 and Mobile ·

Open the interactive lesson →
  1. How the web works (client, server, HTTP)
  2. HTML basics and the document structure
  3. Elements and attributes
  4. Text, links, images and lists
  5. Tables and forms
  6. Block vs inline, semantic tags and the tag reference
  7. CSS basics: syntax, three ways to apply, the cascade
  8. CSS selectors
  9. Box model, units, colours, display and position
  10. Flexbox and Grid
  11. Responsive design, media queries and CSS variables
  12. HTML and CSS in a UI5 app (bootstrap, themes, custom CSS)
  13. Interview questions

The web basics a SAPUI5 developer needs: how a browser talks to a server, how an HTML page is built, and how CSS styles and lays it out. UI5 renders the HTML for you, but you still read it in the browser DevTools every day, write the index.html bootstrap, add custom CSS and choose themes. JavaScript, jQuery and Node.js follow on SAPUI5 › 02 · JavaScript, jQuery & Node.js.

Part 1 – How the web works (client, server, HTTP)

The web is a client–server system. The client (a browser) sends an HTTP request; the server answers with an HTTP response. HTTP is stateless: every request carries everything the server needs (URL, headers, cookies or token). HTTPS is HTTP encrypted with TLS.

HTTP request and response between browser and server

Part

Request

Response

First line

Method + URL, e.g. GET /index.html

Status code, e.g. 200 OK, 404 Not Found

Headers

Accept, Content-Type, Authorization, Cookie, Accept-Language

Content-Type, Cache-Control, Set-Cookie, ETag

Body

Optional – data for POST / PUT / PATCH (JSON, form data)

HTML, CSS, JavaScript, images, JSON or XML

HTTP methods and status codes

Method

Meaning

Typical OData use

GET

Read a resource (no body, no side effects)

Read an entity set or one entity

POST

Create a resource, or trigger an action

Create an entity, call an action, $batch

PUT

Replace the whole resource

Full update of an entity

PATCH

Change only the fields sent (partial update)

Partial update (V4 default; MERGE in V2)

DELETE

Remove a resource

Delete an entity

Code

Meaning

When you see it

200 OK

Success with a body

Read worked

201 Created

Resource created

After a POST

204 No Content

Success without a body

After PUT / PATCH / DELETE

304 Not Modified

Cached copy is still valid

Static files, $metadata

400 Bad Request

Request is wrong (syntax, validation)

Wrong filter, invalid value

401 Unauthorized

Not logged in / no valid credentials

Session expired

403 Forbidden

Logged in but not allowed

Missing role or authorization; missing CSRF token

404 Not Found

URL or entity does not exist

Wrong service path or key

500 Internal Server Error

The server code failed

ABAP dump behind an OData call

  • Ways a browser sends requests: typing a URL or clicking a link (GET), submitting a <form> (GET or POST), and JavaScript calls with fetch() or XMLHttpRequest – called AJAX (page reloads are not needed). UI5 models (ODataModel, JSONModel) send AJAX requests for you.
  • Same-origin policy: JavaScript may only call the server the page came from (same protocol, host and port) unless the server allows it with CORS headers. In UI5 projects a proxy in the UI5 Tooling / SAP BTP destination solves this.
  • Browsers natively understand HTML (structure), CSS (look) and JavaScript (behaviour) – plus SVG, images and WebAssembly. Common browsers: Chrome, Edge, Firefox, Safari. Legacy: Internet Explorer is retired and not supported by current UI5.
  • F12 opens the browser DevTools: Elements (live DOM and CSS), Console, Sources (debugger), Network (every request – essential for OData calls), Application (storage, cookies).

OData itself (SAP Gateway, SEGW, query options) is covered in CORE ABAP › 08 OData.

Part 2 – HTML basics and the document structure

HTML (HyperText Markup Language) describes the structure and meaning of a web page with tags (also called elements). A file of HTML is an HTML document. HTML is a markup language, not a programming language: it has no variables, loops or IF logic. Without JavaScript the page is static; JavaScript (and therefore UI5) changes it at runtime.

HTML5

SAPUI5

What

Markup language (standard)

JavaScript UI framework (library of controls)

Maintained by

WHATWG – the HTML Living Standard

SAP (OpenUI5 is the open-source core)

You write

Tags: <p>, <input>, <table>

Controls in XML views / JS: sap.m.Input, sap.m.Table

Result

The browser builds the DOM from it

UI5 renders controls into HTML + CSS at runtime

HTML versions

Version

Year

Note

HTML (first tag set)

1991

Tim Berners-Lee's original tags

HTML 2.0

1995

First standard (IETF RFC 1866)

HTML 3.2

1997

W3C Recommendation (HTML 3.0 was a draft only)

HTML 4.01

1999

CSS for presentation, many old tags deprecated

XHTML 1.0

2000

HTML written as strict XML

HTML5

2014

W3C Recommendation: semantic tags, audio/video, canvas, new input types

HTML 5.1 / 5.2

2016 / 2017

W3C snapshots

HTML Living Standard

since 2019 the only spec

Maintained by WHATWG (Apple, Google, Microsoft, Mozilla); no version numbers – it is updated continuously

  • "HTML5" today is simply the common name for modern HTML. CSS is still specified by the W3C.

The skeleton of every page

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sales Orders</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/app.js" defer></script>
</head>
<body>
<h1>Sales Orders</h1>
<p>Welcome to the order overview.</p>
</body>
</html>

Tag

Purpose

<!DOCTYPE html>

Tells the browser this is a modern HTML document (standards mode). Not a tag, a declaration.

<html lang="en">

Root element; lang helps screen readers, spell check and translation

<head>

Information about the page – not shown: title, meta, CSS links, scripts

<meta charset="utf-8">

Character encoding (umlauts, €, any language)

<meta name="viewport" …>

Use the device width on phones – required for responsive pages and UI5/Fiori on mobile

<title>

Text in the browser tab, bookmarks and search results

<link rel="stylesheet">

Loads an external CSS file

<script src defer>

Loads JavaScript; defer runs it after the HTML is parsed, in order (type="module" behaves the same). async runs it as soon as it has downloaded, without waiting for the HTML, and several async scripts run in any order: use it only for independent scripts (e.g. analytics)

<body>

Everything the user sees

  • <head> is the invisible page header. Do not confuse it with <header>, a visible semantic block inside <body> (Part 6).

The DOM tree

The browser parses the HTML into a tree of objects – the DOM (Document Object Model). Every element, attribute and piece of text becomes a node; nested tags become child nodes. JavaScript reads and changes the page through the DOM API (→ see SAPUI5 › 02), and UI5 controls write their HTML into it. See the live DOM in DevTools › Elements.

DOM tree of the page skeleton: document, html with lang attribute, head with meta and title, body with h1 and p, and their text nodes

Part 3 – Elements and attributes

An element = start tag + content + end tag. Attributes go into the start tag as name="value" pairs.

<a href="https://ui5.sap.com" target="_blank" title="SAPUI5 SDK">Open the SDK</a>
<!-- start tag with attributes --><!-- content --><!-- end tag -->
  • Write tag and attribute names in lowercase and always quote attribute values.
  • Elements can be nested but must close in reverse order: <p><b>text</b></p>, never <p><b>text</p></b>.
  • Void (empty) elements have no content and no end tag: br, hr, img, input, meta, link, area, base, col, embed, source, track, wbr.
  • HTML is forgiving (browsers repair mistakes). XML views in UI5 are not: they must be well-formed XML – every tag closed (<Button />), attributes quoted, case-sensitive.
  • Comments: <!-- not shown -->. Character entities for reserved characters: &lt; (<), &gt; (>), &amp; (&), &quot; ("), &nbsp; (non-breaking space).

Common attributes

Attribute

Used on

Purpose

id

any (global)

Unique name of one element – for CSS #id, JavaScript and labels

class

any (global)

One or more style classes, space-separated – for CSS .class

style

any (global)

Inline CSS for this element (Part 7)

title

any (global)

Extra information, shown as a tooltip

lang

any (global), mostly <html>

Language of the content

hidden

any (global)

Element is not displayed

tabindex

any (global)

Keyboard focus order (0 = focusable, -1 = only by script)

data-*

any (global)

Your own data, e.g. data-order-id="4711"; read in JS via dataset. UI5 reads its bootstrap configuration from data-sap-ui-* attributes

role, aria-*

any (global)

Accessibility information for screen readers (UI5 controls set them for you)

href

<a>, <link>

Target URL

src

<img>, <script>, <iframe>

Source file

alt

<img>

Alternative text if the image cannot be shown or seen – required

width, height

<img>, <video>

Reserve the space – avoids layout jumps while loading

Part 4 – Text, links, images and lists

Headings, paragraphs and text formatting

Tag

Meaning

<h1> … <h6>

Headings; <h1> most important (one per page), <h6> least. Do not pick them for size – use CSS

<p>

Paragraph – starts on a new line with space above and below

<br> / <hr>

Line break / thematic break (horizontal rule)

<pre>

Preformatted text – keeps spaces and line breaks

<strong> / <b>

Important text / text drawn attention to (both bold by default)

<em> / <i>

Stressed emphasis / alternate voice, technical term (both italic)

<mark>, <small>

Highlighted text, side comment / fine print

<del>, <ins>, <s>

Deleted text, inserted text, text that is no longer correct

<sub>, <sup>

Subscript (H₂O), superscript (x²)

<code>, <kbd>, <samp>, <var>

Code, keyboard input, program output, variable

<abbr title>

Abbreviation with its full form as a tooltip

<blockquote>, <q>, <cite>

Long quotation, short inline quotation, title of a work

<address>

Contact information

<bdo dir>, <bdi>

Override / isolate the text direction (right-to-left languages)

<time>, <data>

Machine-readable date/time or value

Links

<a href="orders.html">Orders</a>                       <!-- relative link        -->
<a href="https://ui5.sap.com" target="_blank">SDK</a>  <!-- opens a new tab      -->
<a href="#items">Jump to items</a>                     <!-- anchor on same page  -->
<a href="mailto:[email protected]">Mail us</a>       <!-- opens the mail app   -->

<!-- an image inside <a> becomes an image link -->
<a href="orders.html"><img src="icon.png" alt="Orders"></a>
  • The mouse pointer turns into a hand over a link. In UI5 use sap.m.Link; app navigation uses the router and the URL hash (→ see SAPUI5 › 04 · Data, Binding & Navigation).

Images and favicon

<img src="images/logo.png" alt="Company logo" width="160" height="40" loading="lazy">
<link rel="icon" href="/favicon.ico" type="image/x-icon">   <!-- in <head> -->
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
  • The image is linked, not embedded: <img> reserves a space and the browser loads the file separately. src and alt are required; loading="lazy" loads it only when it scrolls into view.
  • The favicon is the small icon in the browser tab next to the title, usually favicon.ico in the web root.
  • Related: <figure> + <figcaption> (image with caption), <picture> + <source> (different files per screen size), <svg> (vector graphics), <canvas> (drawing by script), <video>, <audio>, <track>, <iframe> (another page inside the page), image maps with <map> and <area>.

Lists

<ul>  <!-- unordered: bullets -->
<li>Create order</li>
<li>Approve order</li>
</ul>
<ol>  <!-- ordered: numbers   -->
<li>Log on</li>
<li>Open the app</li>
</ol>
<dl>  <!-- description list   -->
<dt>SO</dt>
<dd>Sales order</dd>
</dl>
  • <li> = list item (inside ul/ol), <dt> = term, <dd> = its description. <menu> is a list of commands (toolbar) and behaves like <ul>.

Part 5 – Tables and forms

Tables

<table>
<caption>Open orders</caption>
<thead>
<tr><th>Order</th><th>Customer</th><th>Amount</th></tr>
</thead>
<tbody>
<tr><td>4711</td><td>Acme Ltd</td><td>1,200.00</td></tr>
<tr><td>4712</td><td>Blue Inc</td><td>850.00</td></tr>
</tbody>
<tfoot>
<tr><td colspan="2">Total</td><td>2,050.00</td></tr>
</tfoot>
</table>

Tag

Meaning

<table>

The table

<caption>

Table title

<thead>, <tbody>, <tfoot>

Header rows, data rows, footer rows

<tr>

Table row

<th> / <td>

Header cell (bold, centred) / data cell; colspan and rowspan merge cells

<colgroup>, <col>

Style whole columns

  • Use tables for tabular data, never for page layout (use Flexbox / Grid). In UI5: sap.m.Table (responsive), sap.ui.table.Table (grid table for many rows).

Forms and input types

<form action="/api/orders" method="post">
<label for="cust">Customer</label>
<input id="cust" name="customer" type="text" required placeholder="Customer name">

<label for="qty">Quantity</label>
<input id="qty" name="quantity" type="number" min="1" max="999" value="1">

<label for="date">Delivery date</label>
<input id="date" name="deliveryDate" type="date">

<label><input name="express" type="checkbox"> Express delivery</label>

<select name="currency">
<option value="EUR" selected>Euro</option>
<option value="USD">US dollar</option>
</select>

<textarea name="note" rows="3"></textarea>
<button type="submit">Create order</button>
</form>

Input type / element

Shows

UI5 control

text, password, email, tel, url

Text field (email/url are validated, mobile keyboards adapt)

sap.m.Input

number, range

Number field with arrows / slider

sap.m.StepInput, sap.m.Slider

date, time, datetime-local

Date / time picker

sap.m.DatePicker, TimePicker, DateTimePicker

checkbox, radio

Tick box / one choice of a group (same name)

sap.m.CheckBox, sap.m.RadioButtonGroup

file

File chooser

sap.ui.unified.FileUploader, sap.m.upload.UploadSet

<select> + <option> / <optgroup>

Drop-down list

sap.m.Select, sap.m.ComboBox

<textarea>

Multi-line text

sap.m.TextArea

<button>

Button (type="submit", "button", "reset")

sap.m.Button

<label for>

Caption linked to a field (click focuses the field, screen readers read it)

sap.m.Label (labelFor)

<fieldset> + <legend>

Group of fields with a title

sap.ui.layout.form.SimpleForm / Form

<datalist>, <output>

Suggestions for an input / a calculated result

Input with suggestions

  • Form attributes: action (target URL), method (get puts the data in the URL, post in the body). Field attributes: name (key sent to the server), value, placeholder, required, min/max, pattern (regex), readonly, disabled, maxlength.
  • Browsers validate required, type="email", min/max and pattern before submitting. Always validate again on the server.

Part 6 – Block vs inline, semantic tags and the tag reference

Semantic page layout and block versus inline elements

Block-level and inline elements

Block-level

Inline

Starts on a new line?

Yes

No – flows inside the text line

Width

Full available width

Only as wide as its content

Width / height / vertical margin

Can be set

Ignored on text elements (use inline-block)

Examples

div, p, h1–h6, ul, ol, li, dl, table, form, fieldset, pre, blockquote, hr, header, nav, main, section, article, aside, footer, figure, details

span, a, strong, em, b, i, code, abbr, label, img, input, button, select, br

Generic container

<div> (division) – groups blocks, no meaning, no look of its own

<span> – groups a piece of text inside a line

  • Block or inline is really the CSS display value each element has by default – CSS can change it. (The HTML standard itself groups elements into content categories such as flow and phrasing content.)
  • Any element can have an id (unique) and one or more classes (class="card highlight") – not only div and span.

Semantic layout tags

Semantic tags say what the content is. Screen readers can jump to the main content or navigation, search engines understand the page, and the code is easier to read than a page full of <div>s.

Tag

Use for

<header>

Introductory part of the page or a section: logo, title, user menu

<nav>

A block of main navigation links

<main>

The unique main content – once per page

<section>

A thematic group of content, normally with a heading

<article>

Self-contained content that makes sense alone: post, product card, comment

<aside>

Side content related to the main content

<footer>

Closing part: copyright, contact, legal links

<details> + <summary>

Expandable block (click the summary to open)

<dialog>

Modal or non-modal dialog box

<search>

Wrapper for a search form

<hgroup>

A heading with its sub-heading

UI5 controls do the same job for you: they render ARIA roles and keyboard handling, and the Fiori page layouts (sap.f.DynamicPage, sap.uxap.ObjectPageLayout) give the header/content/footer structure.

Tag reference by category

Category

Tags

Basic

<!DOCTYPE>, html, head, title, body, h1–h6, p, br, hr, <!-- -->

Meta information

head, meta, base (base URL for relative links), link, style, script, noscript

Text

see the table in Part 4, plus dfn (defining a term), meter (gauge), progress, wbr (possible line break), ruby/rt/rp (East Asian annotations), u (unarticulated annotation), template (hidden content for scripts)

Forms

form, input, textarea, button, select, optgroup, option, label, fieldset, legend, datalist, output

Images and media

img, map, area, canvas, svg, figure, figcaption, picture, source, video, audio, track

Frames and embedding

iframe, embed, object, param

Links

a, link, nav

Lists

ul, ol, li, dl, dt, dd, menu

Tables

table, caption, thead, tbody, tfoot, tr, th, td, colgroup, col

Structure and semantics

div, span, header, nav, main, section, article, aside, footer, hgroup, search, details, summary, dialog, data, time

Obsolete – do not use

font, center, big, tt, strike (use CSS, del or s), acronym (use abbr), dir (use ul), frame, frameset, noframes (use iframe), basefont, applet (use embed/object)

Part 7 – CSS basics: syntax, three ways to apply, the cascade

CSS (Cascading Style Sheets) controls how HTML looks: colours, fonts, spacing, layout, animation and adaptation to screen sizes. It separates content (HTML) from presentation (CSS). Before CSS, styling was done with tags such as <font color="red">, repeated on every element.

Rule syntax

h1 {                /* selector: which elements          */
color: navy;      /* declaration = property: value;     */
font-size: 2rem;  /* declarations end with a semicolon  */
}
  • A rule = selector + declaration block { … }. Each declaration is property: value;.
  • "CSS3" is a historical label: after CSS 2.1 the language is split into separate modules (Selectors, Box model, Flexbox, Grid, Media Queries …) that evolve independently. Today it is just "CSS".

Three ways to apply CSS

<!-- 1. Inline: style attribute on one element -->
<p style="color: red; font-weight: bold;">Overdue</p>

<!-- 2. Internal: <style> block in the <head>, valid for this page -->
<style>
body { background-color: #f5f6f7; }
h1   { color: navy; }
p    { color: #333; }
</style>

<!-- 3. External: separate .css file, linked in the <head> of every page -->
<link rel="stylesheet" href="css/style.css">

Way

Scope

Reuse and maintenance

Inline

One element

Not reusable, hard to maintain, beats normal rules (high priority). Avoid

Internal

One page

Reusable inside that page only

External

Whole site / app

Most reusable: one file changes every page, cached by the browser. Standard way – in UI5 css/style.css registered in manifest.json

Cascade, specificity and inheritance

When several rules set the same property on one element, the cascade decides which wins: first importance (!important), then origin (inline style), then specificity, then source order (later wins).

CSS cascade and specificity ladder
  • Specificity is counted as (ids, classes, elements): #price = 1,0,0; .total or [type] or :hover = 0,1,0; p or ::before = 0,0,1. Compare from the left – one ID beats any number of classes. The universal selector * counts 0.
  • Inheritance: some properties (color, font-*, line-height, text-align, visibility) pass from parent to children; box properties (margin, padding, border, width, background) do not. inherit forces it.
  • !important overrides normal rules but makes CSS hard to maintain – use it only as a last resort.

Part 8 – CSS selectors

Selectors find the elements a rule applies to. Five groups: simple, combinator, pseudo-class, pseudo-element and attribute selectors. jQuery and document.querySelector() use the same syntax (→ see SAPUI5 › 02).

Simple selectors and attribute selectors

Selector

Example

Selects

element

p

All <p> elements

.class

.intro

All elements with class="intro"

element.class

p.intro

Only <p> elements with class intro

#id

#firstName

The element with id="firstName"

*

*

All elements

a, b (grouping)

h1, h2, p

All h1, h2 and p – same rule for several selectors

[attr]

[required]

Elements that have the attribute

[attr="v"]

input[type="text"]

Attribute equals the value

[attr^="v"]

a[href^="https"]

Value starts with

[attr$="v"]

a[href$=".pdf"]

Value ends with

[attr*="v"]

[class*="Margin"]

Value contains

Combinators

Combinator

Example

Selects

Descendant (space)

div p

Every p anywhere inside a div

Child >

div > p

p elements whose direct parent is a div

Adjacent sibling +

h2 + p

The one p that comes directly after an h2 (same parent)

General sibling ~

h2 ~ p

Every p sibling that comes after an h2

Pseudo-classes – an element in a special state

a:hover        { text-decoration: underline; }  /* mouse over         */
input:focus    { outline: 2px solid #0a6ed1; }  /* has keyboard focus */
input:invalid  { border-color: #bb0000; }       /* fails validation   */
tr:nth-child(even) { background: #f5f6f7; }     /* zebra rows         */
li:not(.done)  { font-weight: bold; }           /* negation           */

Group

Pseudo-classes

User action

:hover, :active (being clicked), :focus, :focus-visible, :focus-within

Links

:link (not visited), :visited, :target (element whose id is in the URL #hash)

Form state

:checked, :disabled, :enabled, :required, :optional, :valid, :invalid, :in-range, :out-of-range, :read-only, :read-write, :placeholder-shown

Structure

:first-child, :last-child, :only-child, :nth-child(2), :nth-child(odd), :nth-last-child(2), :first-of-type, :last-of-type, :only-of-type, :nth-of-type(2), :nth-last-of-type(2), :empty (no children, not even text), :root (the <html> element)

Logic

:not(sel), :is(a, b), :where(a, b) (specificity 0), :has(sel) (parent selector: .card:has(img))

Language

:lang(de)

Pseudo-elements – style a part of an element

Pseudo-element

Styles

::before / ::after

Generated content before / after the element's content (needs content: "…";)

::first-letter / ::first-line

First letter / first line of a block of text

::marker

The bullet or number of a list item

::selection

Text the user has selected

::placeholder

Placeholder text of an input

  • Pseudo-classes use one colon (:hover), pseudo-elements two (::before).

Part 9 – Box model, units, colours, display and position

The box model

The browser draws every element as a rectangular box made of four layers, from inside out:

CSS box model: content, padding, border and margin, and how content-box and border-box calculate the width

Layer

What it is

Content

Text, image or child elements; size set by width / height

Padding

Space between content and border; takes the element's background

Border

Line around padding and content (border: 1px solid #ccc;)

Margin

Transparent space outside the border, separates the box from its neighbours

.card {
box-sizing: border-box;  /* width includes padding and border */
width: 300px;
padding: 1rem;           /* all four sides                    */
margin: 0.5rem 1rem;     /* top/bottom 0.5rem, left/right 1rem */
border: 1px solid #d9d9d9;
border-radius: 8px;
}
  • Default box-sizing: content-box: width is the content only, so padding and border make the box bigger. border-box is easier and used by almost every modern stylesheet.
  • Shorthand order is clockwise: margin: top right bottom left; two values = vertical horizontal.
  • Margin collapse: vertical margins of neighbouring blocks overlap – the larger one wins, they are not added.

Units and colours

Unit

Relative to

Use for

px

Absolute CSS pixel

Borders, small fixed sizes

%

Parent's size

Fluid widths

em

Font size of the element itself

Spacing that grows with the text of the component

rem

Font size of the root <html> (usually 16px)

Fonts and spacing – scales with the user's setting (UI5 uses rem)

vw / vh

1% of the viewport width / height

Full-screen sections

fr

Share of free space (Grid only)

Grid columns

  • Colours: names (red), hex (#0a6ed1, short #fff), rgb(10 110 209), rgba(…) / alpha (rgb(0 0 0 / 50%)), hsl(210 91% 43%). In UI5 use theme parameters instead of fixed colours (Part 12).

display

Value

Effect

block

New line, full width (default of div, p …)

inline

Inside the text line, width/height ignored (default of span, a …)

inline-block

In the line, but width, height and vertical margins work

none

Removed from the layout completely – takes no space

flex / grid

Becomes a Flexbox / Grid container for its children (Part 10)

  • display: none removes the element; visibility: hidden hides it but keeps its space. UI5 controls with visible="false" are not rendered at all.

position

Value

Positioned relative to

Stays in normal flow?

static (default)

Not positioned – top/left have no effect

Yes

relative

Its own normal position (shift with top/left)

Yes – original space kept

absolute

The nearest positioned ancestor (not static)

No

fixed

The viewport – stays when scrolling (e.g. cookie bar)

No

sticky

Normal until a scroll threshold, then sticks (e.g. table header)

Yes

  • z-index decides which positioned element lies on top. overflow: auto | hidden | scroll controls content that does not fit.
  • Transitions and animations: transition: background-color 0.2s; animates a property change; @keyframes + animation define longer animations.

Part 10 – Flexbox and Grid

The two modern layout models. Flexbox arranges items in one dimension – a row or a column. Grid arranges them in two dimensions – rows and columns at once. Both replace old tricks with floats and layout tables.

Flexbox main and cross axis, and a CSS grid with spanning items

Flexbox

.toolbar {
display: flex;                   /* children become flex items       */
flex-direction: row;             /* row (default) | column           */
justify-content: space-between;  /* along the main axis              */
align-items: center;             /* along the cross axis             */
flex-wrap: wrap;                 /* allow items to move to a new line */
gap: 1rem;                       /* space between items              */
}
.toolbar .search { flex: 1; }      /* grow and take the remaining space */

Property

Values

Meaning

flex-direction

row, column, row-reverse, column-reverse

Direction of the main axis

justify-content

flex-start, center, flex-end, space-between, space-around, space-evenly

Distribute items along the main axis

align-items

stretch (default), center, flex-start, flex-end, baseline

Align items on the cross axis

flex-wrap

nowrap (default), wrap

Allow several lines

gap

length

Space between items

flex (on an item)

1, 0 0 200px (grow shrink basis)

How an item grows or shrinks

align-self, order (on an item)

as align-items; integer

Override alignment / visual order for one item

Grid

.dashboard {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));  /* as many as fit */
gap: 1rem;
}
.dashboard .wide { grid-column: span 2; }                        /* item covers two columns */

.page {
display: grid;
grid-template-columns: 200px 1fr;
grid-template-areas: "head head"
"nav  main";
}
.page header { grid-area: head; }
.page nav    { grid-area: nav; }
.page main   { grid-area: main; }
  • grid-template-columns / grid-template-rows define the tracks; fr = one share of the free space; repeat(auto-fill, minmax(…)) makes a responsive tile layout without media queries.
  • Items are placed automatically, or with grid-column / grid-row (span 2, 1 / 3) or named grid-template-areas.

Layout need

CSS

UI5 control

Items in a row or column

Flexbox

sap.m.FlexBox, sap.m.HBox, sap.m.VBox

Two-dimensional tiles / cards

Grid

sap.ui.layout.cssgrid.CSSGrid, sap.f.GridContainer

Responsive 12-column layout

Grid-like

sap.ui.layout.Grid (defaultSpan="L4 M6 S12")

Form fields with labels

–

sap.ui.layout.form.SimpleForm (ResponsiveGridLayout)

Part 11 – Responsive design, media queries and CSS variables

Responsive web design means one code base that adapts to every screen: phone, tablet, desktop. HTML and CSS resize, hide, stack or move content. The building blocks are the viewport meta tag, relative units, fluid layouts (Flexbox, Grid) and media queries.

/* mobile first: base rules for small screens ... */
.list { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }

/* ... then extend for wider screens */
@media (min-width: 600px) {
.list { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
.list { grid-template-columns: repeat(4, 1fr); }
.sidebar { display: block; }
}
@media print {
nav, .toolbar { display: none; }
}
  • Media features: min-width, max-width, orientation: portrait, prefers-color-scheme: dark, prefers-reduced-motion, media type print.
  • Without <meta name="viewport" content="width=device-width, initial-scale=1"> phones render the page at desktop width and zoom out – media queries do not work as expected.
  • Newer tools: container queries (@container (min-width: 400px)) react to the size of the parent instead of the screen; :has() styles a parent based on its children.
  • In UI5 most of this is built in: responsive controls, sap.ui.Device (Device.system.phone, Device.media), the content-density classes sapUiSizeCompact (mouse) and sapUiSizeCozy (touch), and responsive layouts such as sap.f.FlexibleColumnLayout.

CSS custom properties (variables)

:root {
--brand-color: #0a6ed1;
--space-m: 1rem;
}
.button {
background: var(--brand-color);
padding: var(--space-m);
color: var(--text-on-brand, #fff);    /* second value = fallback */
}
.dark-mode { --brand-color: #4db1ff; }  /* override for a subtree */
  • Declared with --name, read with var(--name, fallback). They inherit and can be changed at runtime (by a class or JavaScript), which makes them ideal for theming.
  • Native CSS now also supports nesting (.card { & h2 { … } }) in all current browsers.

Note: preprocessors (Sass and LESS)

A preprocessor adds programming features to CSS and compiles to plain CSS, because browsers only understand CSS. Sass (Syntactically Awesome Style Sheets) has two syntaxes: .scss (a superset of CSS) and the indented .sass. Dart Sass is the maintained compiler; modules are loaded with @use (the old @import is deprecated).

$brand: #0a6ed1;                 // Sass variable
.toolbar {
background: $brand;
.title { font-weight: bold; }  // nesting
}
  • A variable declared inside a block is local; !global assigns the top-level variable from inside a block (the variable should already exist at the top level).
  • LESS is a similar preprocessor (@brand: #0a6ed1;) – SAPUI5 themes are written in LESS. Many preprocessor features (variables, nesting) are now native CSS.

Part 12 – HTML and CSS in a UI5 app (bootstrap, themes, custom CSS)

In UI5 you hardly write HTML tags: views describe controls, and each control's renderer creates the HTML and CSS classes. The one HTML file you do write is index.html (for standalone apps; in the Fiori launchpad the launchpad itself bootstraps UI5).

From XML view to HTML: you write controls in a view, UI5 builds a control tree, renderers write the HTML, the browser applies theme CSS and your own CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orders</title>
<script id="sap-ui-bootstrap"
src="https://ui5.sap.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_horizon"
data-sap-ui-resource-roots='{"my.orders": "./"}'
data-sap-ui-on-init="module:sap/ui/core/ComponentSupport"
data-sap-ui-compat-version="edge"
data-sap-ui-async="true">
</script>
</head>
<body class="sapUiBody" id="content">
<div data-sap-ui-component data-name="my.orders" data-id="container"
data-settings='{"id": "orders"}'></div>
</body>
</html>
  • The <script id="sap-ui-bootstrap"> loads the UI5 core; the data-sap-ui-* custom attributes are its configuration: theme, where your namespace lives, what to run on init, asynchronous loading. Details: → see SAPUI5 › 03 · SAPUI5 Fundamentals.
  • sapUiBody gives the page the theme background. For OpenUI5 the CDN is https://sdk.openui5.org/resources/sap-ui-core.js.
  • UI5 recommends CSP-compliant pages: no inline scripts or onclick attributes, so the start-up code lives in a module (data-sap-ui-on-init="module:…").
  • Configuration options are written in kebab-case (data-sap-ui-resource-roots, data-sap-ui-on-init); camelCase forms such as data-sap-ui-oninit or bindingSyntax come from samples older than UI5 1.120. compat-version must be edge, and asynchronous loading is the only mode that has a future (UI5 2.x drops synchronous loading).

Themes and theming

  • A theme is the complete visual design of all controls. Current default: sap_horizon (Morning Horizon), with sap_horizon_dark (Evening Horizon) and the high-contrast sap_horizon_hcb / sap_horizon_hcw. Previous theme: sap_fiori_3 (Quartz, still available). Removed: sap_belize (deprecated in 1.120, removed in 1.136) and Blue Crystal – apps that still name them must switch to Horizon.
  • Set the theme in the bootstrap (data-sap-ui-theme), with the URL parameter ?sap-ui-theme=sap_horizon_dark, or in the launchpad user settings (Appearance).
  • SAP themes are written in LESS and compiled to CSS by the theme build. Colours, fonts and sizes are theme parameters (e.g. sapBrandColor, sapBackgroundColor); the SAP theming base content also provides them as CSS custom properties (var(--sapBrandColor)), so custom CSS can follow the active theme.
  • SAP Theme Designer (SAP BTP, or transaction /UI5/THEME_DESIGNER on ABAP systems) creates a company theme – logo, brand colours – on top of an SAP theme without code; it works for all apps.

Custom CSS in an app

// manifest.json
"sap.ui5": {
"resources": {
"css": [{ "uri": "css/style.css" }]
}
}
/* css/style.css – own classes, theme parameters as variables */
.myOrderTitle {
color: var(--sapBrandColor);
font-weight: bold;
}
<!-- XML view: standard classes first, own class only when needed -->
<Panel class="sapUiResponsiveMargin">
<Title text="{i18n>title}" class="myOrderTitle sapUiSmallMarginBottom" />
</Panel>
  • Prefer the standard CSS classes: margins sapUiTinyMargin, sapUiSmallMargin, sapUiMediumMargin, sapUiLargeMargin (+ Top, Bottom, Begin, End), sapUiResponsiveMargin, sapUiNoMargin, padding sapUiContentPadding, sapUiResponsiveContentPadding; density sapUiSizeCompact / sapUiSizeCozy.
  • Add classes in XML with class="…" or in JavaScript with oControl.addStyleClass("myClass").
  • Do not override internal UI5 classes (.sapMBtn…) or use !important – they are not a stable API and break with upgrades or theme changes. Begin/End classes switch automatically for right-to-left languages.
  • Fiori design rules (spacing, colours, layouts) are in the SAP Fiori design guidelines – see SAP Fiori › 01 · SAP Fiori Design & Architecture.

Part 13 – Interview questions

1. What is the difference between HTML5 and SAPUI5?

HTML5 is the markup language standard (WHATWG Living Standard) that describes page structure. SAPUI5 is SAP's JavaScript UI framework: you use its controls in XML views, and UI5 renders them into HTML and CSS in the browser.

2. What is the DOM?

The Document Object Model – the tree of objects the browser builds when it parses the HTML. Each element, attribute and text is a node. JavaScript reads and changes the page through the DOM; you can inspect it in DevTools › Elements.

3. What is the difference between <head> and <header>?

<head> holds invisible information about the page (title, meta, CSS, scripts). <header> is a visible semantic block in the body, such as the page banner with logo and title.

4. Block-level vs inline elements?

Block elements (div, p, h1, ul, table, section …) start on a new line and take the full width. Inline elements (span, a, strong, img, input …) stay in the text line and are only as wide as their content. It is the default CSS display value and can be changed.

5. Why use semantic tags?

They describe the meaning of content (header, nav, main, article, footer), which helps screen readers, search engines and other developers. A <div> carries no meaning.

6. What does the viewport meta tag do?

<meta name="viewport" content="width=device-width, initial-scale=1"> tells mobile browsers to use the real device width instead of a zoomed-out desktop width. Without it responsive layouts and UI5 on phones do not work properly.

7. What are the three ways to apply CSS, and which is best?

Inline (style attribute, one element), internal (<style> in the head, one page) and external (linked .css file, whole site). External is best: reusable, cached, one place to maintain. In UI5 it is css/style.css registered in the manifest.

8. How does CSS decide which rule wins?

The cascade: !important first, then inline styles, then specificity (ids > classes/attributes/pseudo-classes > elements), and with equal specificity the rule that comes later wins.

9. Explain the box model and box-sizing: border-box.

Every element is a box of content, padding, border and margin. With the default content-box, width covers only the content; with border-box it includes padding and border, which makes sizes predictable.

10. Flexbox or Grid – when do you use which?

Flexbox for one direction (a toolbar row, a vertical list); Grid for two dimensions (dashboards, page layouts, card tiles). In UI5: HBox/VBox/FlexBox for Flexbox, CSSGrid/GridContainer for Grid.

11. How do you make a page responsive?

Viewport meta tag, relative units (rem, %), fluid Flexbox/Grid layouts and media queries (mobile first with min-width). UI5 adds responsive controls, sap.ui.Device and the compact/cozy density classes.

12. How do you style a UI5 app without breaking upgrades?

Use the theme (or a custom theme from the Theme Designer), standard classes such as sapUiSmallMargin, and own classes added with class / addStyleClass in css/style.css, using theme parameters (var(--sapBrandColor)). Never override internal .sapM… classes or rely on !important.

13. What happens between an XML view and the HTML you see in DevTools?

UI5 parses the XML view into a tree of control objects (e.g. a sap.m.Button with its properties). Each control's renderer writes the HTML with SAP's CSS classes and an ID prefixed with the view ID; the browser builds the DOM and applies the theme CSS plus your own classes. When a property changes, UI5 updates the DOM itself. So you work with the control API (byId, binding), and treat the generated HTML as read-only output.

🏠 Start Here · 02 · JavaScript & Node.js ▶ · Sections: CORE ABAP | OOPS ABAP | ABAP on HANA | Clean Core | RAP | ABAP Points | SAP Fiori | SAPUI5 | Mobile Development (MDK) | BTP Foundations | BTP Development | CAP | SAP Build | ABAP on BTP | Integration Suite | SAP Business AI | SAP BASIS | Security | SAP SDLC

Functional: FICO ABAP | TRM ABAP | VIM | SAP BIS | SD ABAP | MM ABAP | PP ABAP | QM ABAP | PM ABAP | PS ABAP | EWM | TM ABAP | EHS ABAP | HR ABAP | BW | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP