diff --git a/apps/files_sharing/css/public.scss b/apps/files_sharing/css/public.scss
index 268430569054c93996bb6b2201a1f02d73ce45f2..3b53b1ce2a740ce8f5dc98794697de2f42327d30 100644
--- a/apps/files_sharing/css/public.scss
+++ b/apps/files_sharing/css/public.scss
@@ -186,22 +186,6 @@ thead {
 	text-align: left;
 }
 
-/* Needed to ellipsize long header text on share page */
-#body-login #header-left,
-#body-login .header-left {
-	overflow: hidden;
-}
-
-#header .header-shared-by  {
-	color: var(--color-primary-text);
-	position: relative;
-	font-weight: 300;
-	font-size: 11px;
-	line-height: 11px;
-	overflow: hidden;
-	text-overflow: ellipsis;
-}
-
 #note-content {
 	padding: 5px;
 	display:inline-block;
diff --git a/core/css/header.scss b/core/css/header.scss
index 356ee93cf26a296aa161fee8bb2e4f570748e67a..afda272ea780feafc55336cc9379e7d2b6277d38 100644
--- a/core/css/header.scss
+++ b/core/css/header.scss
@@ -64,6 +64,7 @@
 	box-sizing: border-box;
 	opacity: 1;
 	align-items: center;
+	display: flex;
 	flex-wrap: wrap;
 	overflow: hidden;
 
@@ -211,9 +212,9 @@
 	}
 
 	#header-left, .header-left {
-		flex: 0 0;
-		flex-grow: 1;
+		flex: 1 0;
 		white-space: nowrap;
+		min-width: 0;
 	}
 
 	#header-right, .header-right {
@@ -269,6 +270,7 @@
 	}
 }
 
+/* TODO: move into minimal css file for public shared template */
 /* only used for public share pages now as we have the app icons when logged in */
 .header-appname {
 	color: var(--color-primary-text);
@@ -279,6 +281,18 @@
 	padding-right: 5px;
 	overflow: hidden;
 	text-overflow: ellipsis;
+	// Take full width to push the header-shared-by bellow (if any)
+	flex: 1 1 100%;
+}
+
+.header-shared-by  {
+	color: var(--color-primary-text);
+	position: relative;
+	font-weight: 300;
+	font-size: 11px;
+	line-height: 11px;
+	overflow: hidden;
+	text-overflow: ellipsis;
 }
 
 /* do not show menu toggle on public share links as there is no menu */
diff --git a/core/templates/layout.public.php b/core/templates/layout.public.php
index 73e3e0f0b463ccf565bbe81b4359ad4c0f9ac4e5..e0445f419c408e75a3b0be57701f1e961c511a03 100644
--- a/core/templates/layout.public.php
+++ b/core/templates/layout.public.php
@@ -39,17 +39,17 @@
 			<span id="nextcloud">
 				<div class="logo logo-icon svg"></div>
 				<h1 class="header-appname">
-					<?php if (isset($template)) {
-			p($template->getHeaderTitle());
-		} else {
-			p($theme->getName());
-		} ?>
+					<?php if (isset($template) && $template->getHeaderTitle() !== '') {
+						p($template->getHeaderTitle());
+					} else {
+						p($theme->getName());
+					} ?>
 				</h1>
+				<?php if (isset($template) && $template->getHeaderDetails() !== '') { ?>
 				<div class="header-shared-by">
-					<?php if (isset($template)) {
-			p($template->getHeaderDetails());
-		} ?>
+					<?php p($template->getHeaderDetails()); ?>
 				</div>
+				<?php } ?>
 			</span>
 		</div>