Adding a background image to a page in Oracle APEX can transform the look and feel of your application, helping to brand or visually enrich the user experience. Whether you're applying a subtle texture or a full-screen photo, Oracle APEX makes it easy to set a custom background using CSS. In this blog post, we’ll walk through how to display a page background image in Oracle APEX using built-in features, and how to ensure it scales and performs well across different devices.How to Display a Page Background Image in Oracle APEX
-
Upload the Background Image to Static Files
-
Go to Shared Components → Static Application Files
-
Click Upload File and choose your image file (e.g.,
background.jpg
) -
After uploading, note the file URL (right-click the file and copy link)
-
-
Add CSS to Reference the Background Image
-
Navigate to the target page
-
Click Page → CSS → Inline and add the following CSS:
body { background-image: url('#APP_IMAGES#background.jpg'); background-size: cover; background-repeat: no-repeat; background-position: center center; background-attachment: fixed; }
-
Replace
background.jpg
with your actual file name if different
-
-
Optional: Apply Background to Specific Page Elements
If you want the background image to apply only to a specific region or container:#t_Body { background-image: url('#APP_IMAGES#background.jpg'); background-size: cover; background-repeat: no-repeat; }
Preview the Page
Run the page and check how the background image appears. Make adjustments tobackground-size
orbackground-position
based on your layout and image dimensions.
How to Display a Page Background Image in Oracle APEX
Adding a background image to an APEX page can enhance the user interface and make the application visually appealing. This can be done using CSS, Static Application Files, or inline styles. Below are multiple approaches to accomplish this in Oracle APEX.
1. Using CSS to Set a Background Image
The most efficient way to apply a background image is by using CSS.
Steps to Add a Background Image via CSS
Open Oracle APEX Page Designer.
Select the Page Attributes section.
Scroll down to the CSS section and find Inline CSS.
Add the following CSS code:
body {
background-image: url('&APP_IMAGES.background.jpg');
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
Click Save and Run the page to see the background image.
Explanation of CSS Properties:
background-image: Specifies the image to be used.
background-size: cover: Ensures the image covers the full page.
background-repeat: no-repeat: Prevents the image from repeating.
background-attachment: fixed: Keeps the background image static when scrolling.
background-position: center: Centers the image on the page.
2. Using a Static Application File for Background Image
If the image is stored in APEX under Static Application Files, reference it dynamically.
Steps to Upload and Use a Static File
Navigate to Shared Components > Static Application Files.
Click Upload File, select the image, and upload it.
Copy the file reference URL from the uploaded file.
Apply the CSS in Page Designer under Inline CSS:
body {
background-image: url('#APP_FILES#background.jpg');
background-size: cover;
background-repeat: no-repeat;
}
APEX will dynamically replace #APP_FILES# with the correct image path.
3. Setting Background Image via Page Templates
If the same background image should be applied to all pages, update the Page Template.
Steps to Modify Page Template for Background Image
Open Shared Components.
Click on Themes and choose the theme in use (e.g., Universal Theme).
Select Page Templates.
Edit the Standard Page Template.
Find the <body> tag inside the Template Definition.
Add the following inline CSS before </body>:
<style>
body {
background-image: url('&APP_IMAGES.background.jpg');
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
Save changes and apply them to all pages using the template.
4. Using JavaScript to Dynamically Change Background Image
If the background image should change dynamically based on user actions, use JavaScript.
Steps to Change Background Image Using JavaScript
In Page Designer, navigate to Page Attributes.
Under Execute when Page Loads, add the following JavaScript:
document.body.style.backgroundImage = "url('&APP_IMAGES.dynamic_background.jpg')";
document.body.style.backgroundSize = "cover";
document.body.style.backgroundRepeat = "no-repeat";
This script changes the background when the page loads.
5. Changing Background Based on Page Conditions
To change the background based on specific page numbers or conditions:
Go to Page Designer > Execute when Page Loads.
Add the following JavaScript:
if ($v('P1_USER_ROLE') === 'Admin') {
document.body.style.backgroundImage = "url('&APP_IMAGES.admin_background.jpg')";
} else {
document.body.style.backgroundImage = "url('&APP_IMAGES.user_background.jpg')";
}
This changes the background dynamically based on user roles.
Displaying a background image in Oracle APEX can be done using CSS, Static Application Files, or JavaScript. The best approach depends on the application requirements. Using CSS is ideal for static backgrounds, while JavaScript is useful for dynamic changes based on conditions or user interactions.
EXAMPLE:
Step 1 – Click on the image from Shared Components > Static Application Files
Step 2 - Copy the reference value
Your reference should look like this:
#APP_FILES#JMarketplace/MarketplaceReactive.Complex.jpg
Step 3 – Go to the “Page” level of the page and change the inline CSS
Code:
#t_PageBody {
background-image: url(#APP_FILES#Marketplace/tplaceReactive.Complex.jpg);
background-size: 100% Auto;
}
Should look like this:
Best Practices for Background Images in Oracle APEX
-
Use Optimized Images to reduce load time; keep images under 500KB if possible.
-
Use high-contrast content to ensure text remains readable over the background.
-
Test on multiple screen sizes (desktop, tablet, mobile) to ensure proper scaling.
-
Use
background-size: cover
for a full-screen image that adjusts automatically. Avoid clutter—make sure your image supports, not distracts from, the content.
Oracle APEX Documentation Links
Conclusion
Displaying a background image in Oracle APEX is a simple way to enhance the visual design of your application. With just a few steps—uploading your image, adding inline CSS, and fine-tuning layout—you can give your APEX page a professional, custom appearance. Just be sure to follow best practices for performance and accessibility to ensure your background looks great and works well for all users.