<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Martin Klestil</title>
    <description>The latest articles on DEV Community by Martin Klestil (@tintildev).</description>
    <link>https://dev.to/tintildev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F307724%2Ff8f374cd-f971-4a78-bc00-43e6a708bfc0.png</url>
      <title>DEV Community: Martin Klestil</title>
      <link>https://dev.to/tintildev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tintildev"/>
    <language>en</language>
    <item>
      <title>CSS inheritance</title>
      <dc:creator>Martin Klestil</dc:creator>
      <pubDate>Fri, 08 Aug 2025 19:09:02 +0000</pubDate>
      <link>https://dev.to/tintildev/css-vererbung-58id</link>
      <guid>https://dev.to/tintildev/css-vererbung-58id</guid>
      <description>&lt;h2&gt;
  
  
  What is CSS inheritance?
&lt;/h2&gt;

&lt;p&gt;In CSS, certain properties can be automatically passed from a parent element to its child elements.&lt;br&gt;
This is called &lt;em&gt;inheritance&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why is it important?
&lt;/h3&gt;

&lt;p&gt;Thanks to inheritance, you don't have to redefine each property for each individual element.&lt;br&gt;
This saves time and ensures a consistent design.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is inherited?
&lt;/h3&gt;

&lt;p&gt;Not all CSS properties are automatically inherited.&lt;br&gt;
Typical inheritable properties include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;color&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font-family&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;line-height&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, if you assign a text color to a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, this color will be inherited by the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements it contains.&lt;/p&gt;
&lt;h4&gt;
  
  
  Code Example
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;
&amp;lt;p&amp;gt;Text in a Paragraph&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div {
color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element automatically inherits the font color of the &lt;/p&gt;.
&lt;h3&gt;
  
  
  What is not inherited?
&lt;/h3&gt;

&lt;p&gt;Non-inherited properties must be set explicitly for each element.&lt;br&gt;
Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;margin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;padding&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;border&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;background&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Code Example:
&lt;/h4&gt;


&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;
This is the parent element with padding.
&amp;lt;p&amp;gt;This is the child element&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div{
border: solid 1px red;
}
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;If you want to explicitly inherit this, you must set it in the child element using inherhit.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;
This is the parent element with padding.
&amp;lt;p style="border: inherit;"&amp;gt;This is the child element&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Keywords &lt;code&gt;inherit&lt;/code&gt;, &lt;code&gt;initial&lt;/code&gt;, &lt;code&gt;unset&lt;/code&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;inherit&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Resets the property to its &lt;strong&gt;default value&lt;/strong&gt; (as defined by the browser).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;unset&lt;/code&gt; (combination of inherit and initial)&lt;br&gt;
Combines both worlds:&lt;/p&gt;

&lt;p&gt;For inheritable properties → &lt;code&gt;inherit&lt;/code&gt;&lt;br&gt;
For non-inheritable properties → &lt;code&gt;initial&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  When should you use inheritance specifically?
&lt;/h4&gt;

&lt;p&gt;When multiple child elements share the same properties, inheritance is worthwhile:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
font-family: Arial, sans-serif;
color: #333;
}
&lt;/code&gt;&lt;/pre&gt;



&lt;h4&gt;
  
  
  When is it better not to use it?
&lt;/h4&gt;

&lt;p&gt;Inheritance &lt;strong&gt;only&lt;/strong&gt; works from top to bottom – from parent to child.&lt;/p&gt;

&lt;p&gt;If you want to specifically change the design of a single element, you should &lt;strong&gt;address it directly&lt;/strong&gt; or work with classes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;CSS inheritance is a powerful tool for making your stylesheet more efficient and clearer.&lt;br&gt;
If you use it consciously, you save time and avoid repetition in your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks
&lt;/h2&gt;

&lt;p&gt;Thank you for reading this far! I'm still new to writing articles and have a lot to learn. I appreciate for your feedback.&lt;br&gt;
Happy coding 😊&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>css</category>
      <category>learning</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JavaFX Notepad Tutorial</title>
      <dc:creator>Martin Klestil</dc:creator>
      <pubDate>Sat, 29 Mar 2025 10:47:49 +0000</pubDate>
      <link>https://dev.to/tintildev/javafx-notepad-tutorial-52hk</link>
      <guid>https://dev.to/tintildev/javafx-notepad-tutorial-52hk</guid>
      <description>&lt;h2&gt;
  
  
  Hello World!
&lt;/h2&gt;

&lt;p&gt;I would like to share my learning journey with JavaFX, this is my notepad project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftss0omen3l8wgy8zmfml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftss0omen3l8wgy8zmfml.png" alt=" " width="642" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Before starting
&lt;/h2&gt;

&lt;p&gt;Java Version: openjdk 22&lt;br&gt;
IDE: IntelliJ Community Edition&lt;br&gt;
Build Tool: Maven&lt;/p&gt;

&lt;h2&gt;
  
  
  My Plan
&lt;/h2&gt;

&lt;p&gt;If you look at Notepad you can break it down into a few parts. Menu, TextArea, Icon, Title, Control (Close...).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fure2w79wxo4ipbwlx242.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fure2w79wxo4ipbwlx242.png" alt=" " width="727" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Time to code
&lt;/h2&gt;

&lt;p&gt;I create with IntelliJ a new JavaFX Project and start with a mvc architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgaq9w1hd12s7im0krxrm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgaq9w1hd12s7im0krxrm.png" alt=" " width="755" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  MainView
&lt;/h3&gt;

&lt;p&gt;The MainView gives me my root element for the Scene, this is where the text area and the menu are added.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg7g1skynho1rnz35gq0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg7g1skynho1rnz35gq0d.png" alt=" " width="545" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Menu
&lt;/h3&gt;

&lt;p&gt;Next we create the menu. I have created helper functions for the individual menu areas.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkp8n4omm48b39opr8x3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkp8n4omm48b39opr8x3.png" alt=" " width="757" height="636"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Model
&lt;/h2&gt;

&lt;p&gt;Than we must implement some logic, to make the Menu clickable, editable the text ...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F093mhbj9tqts8x46npti.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F093mhbj9tqts8x46npti.png" alt=" " width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can play around here and add all the features you want.&lt;/p&gt;

&lt;h2&gt;
  
  
  Controller
&lt;/h2&gt;

&lt;p&gt;My controller only connects the view to the models.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thank you for reading this far! I'm still new to writing articles and have a lot to learn. I appreciate for your feedback.&lt;br&gt;
Happy coding 😊&lt;/p&gt;

</description>
      <category>java</category>
      <category>javafx</category>
      <category>tutorial</category>
      <category>opensource</category>
    </item>
    <item>
      <title>JavaFX Dock project</title>
      <dc:creator>Martin Klestil</dc:creator>
      <pubDate>Tue, 27 Aug 2024 08:51:16 +0000</pubDate>
      <link>https://dev.to/tintildev/javafx-dock-project-1ibe</link>
      <guid>https://dev.to/tintildev/javafx-dock-project-1ibe</guid>
      <description>&lt;h2&gt;
  
  
  Hello World!
&lt;/h2&gt;

&lt;p&gt;I would like to share my learning journey with JavaFX by demonstrating a small project in the form of a 'dock'. The goal of this project is to create a bar at the bottom of the screen where program icons can be placed and launched directly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnvdkzh8r57dqoeickeac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnvdkzh8r57dqoeickeac.png" alt="Dock project" width="800" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project idea
&lt;/h2&gt;

&lt;p&gt;I came across this project as part of the Udemy course '&lt;a href="https://www.udemy.com/course/javafx-java-programme-mit-oberflachen-guis-erstellen/" rel="noopener noreferrer"&gt;JavaFX - Creating Java programs with interfaces / GUIs&lt;/a&gt;'.&lt;/p&gt;

&lt;p&gt;I developed my own interpretation and expanded and improved the project according to my ideas.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before starting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Java Version&lt;/strong&gt;: openjdk 22&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IDE&lt;/strong&gt;: IntelliJ Community Edition&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Tool&lt;/strong&gt;: Maven&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create Project
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fym4w1wtthy1o3rz1ph32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fym4w1wtthy1o3rz1ph32.png" alt="create project in intellij" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Creating a JavaFX project in IntelliJ is easy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Structure
&lt;/h3&gt;

&lt;p&gt;I'm following the MVC architecture, with separate packages for the model, view, and controller.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class App extends Application {
    public void start(Stage stage) throws IOException {
        //MVC
        MyView view = new MyView();
        MyController controller = new MyController(view);

        //JavaFX
        Scene scene = new Scene(view.getRoot(), 520, 240);
        stage.setTitle("Hello World!");
        stage.setScene(scene);
        stage.show();
    }
    public static void main(String[] args) {
        launch();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  View
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MyView {
    private Group root = new Group();
    private ImageView imageViewDock;

    private final String[] icons = {"Browser.png", "IDE.png", "Mail.png", "Text.png" };
    private ArrayList&amp;lt;IconImageView&amp;gt; iconsList = new ArrayList&amp;lt;&amp;gt;();

    public MyView() {
        Image image = new Image(getClass().getResourceAsStream("/images/Dock.png"));
        //Dock
        imageViewDock = new ImageView(image);
        imageViewDock.setTranslateX(12);
        imageViewDock.setTranslateY(100);

        root.getChildren().add(imageViewDock);

        for(int i = 0; i &amp;lt; icons.length; i++){
            IconImageView icon = new IconImageView(icons[i]);
            icon.setTranslateX(90+80 * i);
            icon.setTranslateY(100);
            icon.setEffect(new Reflection());
            root.getChildren().add(icon);
            iconsList.add(icon);
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I use the &lt;code&gt;Group&lt;/code&gt; layout as the root element for my scene. Then I create an &lt;code&gt;ImageView&lt;/code&gt; that contains my image for the dock.&lt;br&gt;
Using a for loop, I created the icons and added them to the dock.&lt;/p&gt;

&lt;h4&gt;
  
  
  Icons
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class IconImageView extends ImageView {

    String path = "";

    public IconImageView(String path) {
        this.path = path;
        Image image = new Image(getClass().getResourceAsStream("/images/" + this.path +""));
        this.setImage(image);
        this.setScaleY(0.8);
        this.setScaleX(0.8);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the icons, I created a custom IconImageView class where I defined default values and zoom in/out effects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Controller
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MyController {
    private  MyView view;

    public MyController(MyView view) {
        this.view = view;
        DockHandler dockHandler = new DockHandler();

        //Add Event Handler, exit by 2 clicks
        this.view.getImageViewDock().setOnMouseClicked(dockHandler.getMouseEventEventHandler());

        //Add Event Handler Icons
        ArrayList&amp;lt;IconImageView&amp;gt; iconsList = view.getIconsList();
        for ( int i = 0; i &amp;lt; iconsList.size(); i++){
            iconsList.get(i).setOnMouseClicked(new IconHandler(iconsList.get(i).getPath()).getEventHandler());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The controller connects my view with the model classes. The dockHandler terminates the program when you double-click on the dock.&lt;/p&gt;

&lt;h4&gt;
  
  
  IconHandler
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public IconHandler(String path) {

        eventHandler = new EventHandler&amp;lt;MouseEvent&amp;gt;() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                //Query operating system
                String os = System.getProperty("os.name").toLowerCase();


                if (path.equals("Browser.png")){
                    System.out.println("Browser");
                    if(os.contains("win")){
                        String path = "C:\\Program Files\\Mozilla Firefox\\firefox.exe" ;
                        startProgramm(path);
                    }else if (os.contains("mac")) {
                        String path = "open /Applications/Firefox.app" ;
                        startProgramm(path);
                    }else {
                        System.out.println("Unsupported operating system");
                    }

                } else if 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In IconHandler, check which operating system is used and then open the application for Mac or Windows.&lt;/p&gt;

&lt;h3&gt;
  
  
  App
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        //Transparent
        scene.setFill(Color.TRANSPARENT);
        stage.initStyle(StageStyle.TRANSPARENT);

        stage.show();

        //Position
        //Screen Size
        Rectangle2D screenSize = Screen.getPrimary().getVisualBounds();
        double x = (screenSize.getWidth() - stage.getWidth()) / 2;
        double y = screenSize.getHeight() - stage.getHeight() - 40;
        stage.setX(x);
        stage.setY(y);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, I implemented transparency and positioned the dock correctly on the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future
&lt;/h2&gt;

&lt;p&gt;Currently, some elements, such as paths and images, are still hard-coded. I plan to improve these areas to allow new icons to be added dynamically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thank you for reading this far! I'm still new to writing articles and have a lot to learn. I appreciate any feedback you may have. May the Force be with you. 😊&lt;/p&gt;

</description>
      <category>java</category>
      <category>javafx</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Dark theme with css</title>
      <dc:creator>Martin Klestil</dc:creator>
      <pubDate>Fri, 28 Jul 2023 05:48:55 +0000</pubDate>
      <link>https://dev.to/tintildev/dark-theme-test-4noe</link>
      <guid>https://dev.to/tintildev/dark-theme-test-4noe</guid>
      <description>&lt;p&gt;Hello world, this is my first blog post.🥳&lt;/p&gt;

&lt;p&gt;I've spent the last few days to find an easy way to create dark and light themes using css.&lt;/p&gt;

&lt;p&gt;With the help of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme" rel="noopener noreferrer"&gt;prefers-color-scheme&lt;/a&gt; we can create our own theme for dark or light mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prefers-color-scheme
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That will be use with a media query, to detect if the user has their system set to use a light or dark color theme.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsptlqcjr21s4c5ls06k.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsptlqcjr21s4c5ls06k.PNG" alt="CSS Media Query" width="317" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, comes to the question of how to test the whole thing?&lt;/p&gt;

&lt;h2&gt;
  
  
  Test
&lt;/h2&gt;

&lt;p&gt;Current browsers read the theme preference from the operating system. Luckily there is a way to test this easily.&lt;/p&gt;

&lt;p&gt;Tested with Google Chrome Version 115.x(July 2023).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open developer tools&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open Command Control&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ctrl + Shift + P (Windows)&lt;/li&gt;
&lt;li&gt;Command+Shift+P (Mac)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter Show Rendering&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsow6pqsquqjz7tniq0u.png" alt="Enter Show Rendering" width="555" height="175"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Emulate CSS Media&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmrjs5u97gtka8cerzek.png" alt="Emulate CSS Media" width="347" height="163"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where does it work?
&lt;/h2&gt;

&lt;p&gt;Thanks to the site &lt;a href="https://caniuse.com/?search=prefers-color-scheme" rel="noopener noreferrer"&gt;caniuse.com&lt;/a&gt; we can check CSS commands, there we get a global coverage of 94.93% for prefers-color-scheme (as of July 2023).&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
