One place for hosting & domains


      An Introduction to Python String Interpolation

      During string interpolation a string literal is evaluated and if any placeholders are present, they are substituted by the indicated variable values. String interpolation helps reduce repetition in code and allows for dynamic string substitution. Python string interpolation consists of two parts: a string template and a value, or set of values, that you want to place within that template. To trigger string interpolation, the compiler needs some method of determining where to place the values within the string template. Python provides four techniques to do this, and this guide covers them all. Each string interpolation technique has its own advantages and disadvantages. The four ways to trigger string interpolation are the following:

      • A modulo character (%) placed within a string literal indicates where to make the string replacement and can be followed by string format indicators and variable names that store replacement values.
      • Call the .format() method on your string literal. Use a pair of curly braces ({}) to indicate where to make the string replacement. The .format() method’s arguments indicate the values to use for the string replacement.
      • Precede any string literal by the letter f to use formatted string literals, also referred to as “f-strings”. The string literal can contain curly braces ({}) that delimit a python expression and variables to use for the string substitution.
      • Import the
        String module’s Template class
        into your Python code. Store your string template in a variable using the Template() class. Then, use the Template class’ .substitute() function to indicate which values to use in the string substitution.

      The sections below cover each of the four ways you can use string interpolation in Python.

      The String Modulo Operator and String Formatting

      If code readability is a top concern, the modulo operator (%) method for string interpolation and formatting is a good choice. Its syntax is more concise compared to other string interpolation methods, because it does not require as many formatting arguments. The modulo operator is, however, the least flexible of the methods available for string interpolation. It is also an older string formatting method that may not remain supported as newer versions of Python are released. If you are working with an older Python codebase that uses the string modulo operator, then you may need to become familiar with its syntax.

      The general syntax for string formatting with the string modulo operator is the following:

      %[flags][width][.precision]format_indicator %(values)

      Using String Format Indicators

      String formatting with the modulo operator includes the % character and a format indicator for each of the entries in the string template. A format indicator converts a provided value into the type indicated by the format indicator. The conversion is done before the value is inserted into the string. Python provides the following format indicators:

      • %s: String (performed using the str() function)
      • %d: Integer
      • %f: Floating point
      • %e: Lowercase exponent
      • %E: Uppercase exponent
      • %x: Lowercase hexadecimal
      • %X: Uppercase hexadecimal
      • %o: Octal
      • %r: Raw (performed using the repr() function)
      • %g: Floating point for smaller numbers, lowercase exponent for larger numbers
      • %G: Floating point for smaller numbers, uppercase exponent for larger numbers
      • %a: ASCII (performed using the ascii() function)
      • %c: Converts an int or a char to a character, such as 65 to the letter A

      The values to use for string substitution are placed after another % outside of the string literal. They can appear alone when working with a single value, or within a tuple when working with multiple values. You can use arithmetic calculations to generate a string replacement value, as demonstrated in the example below.

      myVal1 = 10.1
      myVal2 = 2.2
      print("The sum of %s and %s is %s." %(my_val_1, my_val_2, my_val_1+my_val_2))
      print("The sum of %d and %d is %d." %(my_val_1, my_val_2, my_val_1+my_val_2))
      print("The sum of %f and %f is %f." %(my_val_1, my_val_2, my_val_1+my_val_2))
      print("The sum of %e and %e is %E." %(my_val_1, my_val_2, my_val_1+my_val_2))
      print("The sum of %x and %x is %X." %(int(my_val_1), int(my_val_2),
      print("The sum of %o and %o is %o." %(int(my_val_1), int(my_val_2),

      The output shows the result of the various format indicators.

      The sum of 10.1 and 2.2 is 12.3.
      The sum of 10 and 2 is 12.
      The sum of 10.100000 and 2.200000 is 12.300000.
      The sum of 1.010000e+01 and 2.200000e+00 is 1.230000E+01.
      The sum of a and 2 is C.
      The sum of 12 and 2 is 14.

      The format indicators in the first print() statement convert my_val_1, my_val_2, and my_val_1+my_val_2 into strings. The string values are then substituted where the % character is placed within the string literal. The subsequent format indicator examples perform similar substitutions, but instead convert the values to decimals, floating point numbers, exponents, hexadecimal numbers, and octal numbers. Notice that you must convert floating-point values to integer values when working with the %x, %X, or %o format indicators. This is why the int() method is used in the last two print() statements.

      The following code shows the difference between string output and raw output for the same variable value:

      my_val="Hello There!"
      print("%s, it's a lovely day!" %my_val)
      print("%r, it's a lovely day!" %my_val)

      When working with raw output, the compiler doesn’t interpret any of the characters and displays every character that is present in your string. This allows you to use special characters as needed. The second print() statement made use of the raw output format indicator (%r), so the output displays the opening and closing single quotes.

      Hello There!, it's a lovely day!
      'Hello There!', it's a lovely day!

      Using Flags to Modify Output

      The string modulo operator supports flags that further control a string’s formatting. The following examples demonstrate the usage of flags in modulo string formatting.

      The examples below use the variables, my_val_1 and my_val_2 to store the values to embed within the example strings.

      my_val_1 = 10.1
      my_val_2 = 2.2

      The format indicator %5d, uses the 5 flag to indicate that the integers should be formatted with 5 spaces. Since the d portion converts the floating-point numbers to integers, three spaces are placed in front of the integers.

      print("%5d %5d" %(my_val_1, my_val_2))
      10     2

      Similarly, you can pad your output with zeros:

      print("%05d %02d" %(my_val_1, my_val_2))
      00010 02

      To left justify your integers, use the - flag with your string formatting:

      print("%-5d %-5d" %(my_val_1, my_val_2))
      10    2

      It’s possible to achieve more sophisticated formatting using the modulo operator. For example, you can format a floating-point value to have a specific number of digits after the decimal point. You can also add a dollar sign to monetary values. The following code shows both methods.

      print("%07.2f" %my_val_1)
      print("$%1.2f" %my_val_1)

      In the first example, the first part of the format specifier tells the compiler to make the entirety of the output seven digits long (%07). The second part of the format specifier tells the compiler to keep the part after the decimal point limited to two digits (2f). The second example uses a value of one for the entirety of the output, but limits the decimal output to two digits. When you specify a length that can’t possibly hold the entire value, Python still displays the whole value as shown.

      The Python String .format() Method and Positional Arguments

      Python’s str.format() method provides another option for working with string formatting and interpolation. With the str.format() method, it’s possible to obtain any string output you need, however, it may require complex code. Due to its complexity, the .format() method may not always be the best choice. Formatting characters can prove difficult to read and even harder to troubleshoot.

      The str.format() method can be called on any Python string object. Replacement fields are surrounded by curly braces ({}). A replacement field contains the name of a
      keyword argument
      or the numeric index of a positional argument.

      The example below demonstrates using the str.format() with replacement fields and a named keyword argument.

      'My name is {name} and I am {age} years old'.format(name="Frida", age=114)

      The Python interpreter returns the original string. However, the replacement fields are expanded to display the values of the .format() method’s keyword arguments.

      'My name is Frida and I am 114 years old'

      The next example demonstrates using the str.format() with replacement fields and the numeric index of a positional argument.

      'My name is {0} and I am {1} years old'.format('Frida', 114)

      The Python interpreter returns the original string. In this case, the replacement fields are expanded to display the values of the str.format() method’s positional arguments.

      Similar to the modulo method of string formatting, you can use format indicators with your str.format() method’s arguments to further modify your string output. For example, the two variables, my_val_1 and my_val_2 store floating-point numbers.

      my_val_1 = 10.1111
      my_val_2 = 2.2222

      Use the str.format() method and format indicators to adjust the number of digits that are displayed after the decimal point.

      'The first value equals {:.2f} and the second value equals {:.3f}.'.format(my_val_1, my_val_2)

      Python returns the following formatted string:

      'The first value equals 10.11 and the second value equals 2.222.'

      The format indicator {:.2f} specifies that the floating-point value should display two places after the decimal point. While the format indicator {:.3f}, specifies that the floating-point value should display three places after the decimal point.

      The str.format() method supports many format indicators that align your output, and adjust the
      presentation type for string, integer, float, and decimal values

      Python f-strings

      Another way to format strings is with Python f-strings, also known as formatted string literals. As with the other string formatting techniques discussed in this guide, f-strings can contain replacement fields denoted with curly braces ({}). When compared to the str.format() method, the f-string method produces simpler and more readable code. In addition, f-strings are more performant than the modulo operator or the str.format() method.

      When using a Python f-string, you must prefix your string literal with f or F. For example:

      import datetime
      f'The date today is { %d, %Y}'

      The Python interpreter returns the following string:

      'The date today is March 01, 2022'

      The replacement field includes a Python expression and a date format specifier. To achieve the same result using the str.format() method, you need the following code:

      import datetime
      'The date today is {:%B %d, %Y}'.format(

      The f-string version of the code is more succinct and readable than the str.format() version. Similar to str.format(), you should refer to Python’s
      Format Specification Mini-Language documentation
      to learn all the ways that you can format strings using f-strings.

      Python Template Strings

      The Python 3
      Template Class
      is part of the String module. Compared to the other methods described in this guide, template strings provide simpler string substitution. However, it does not support string formatting, like f-strings, str.format(), and the string modulo operator. While this makes Template class strings less powerful, they are considered more secure. For this reason, the Template class is a good choice if you are working with user-generated strings.

      String substitutions are indicated using a $ interpolation character. The $ should be followed by the name of a dictionary key that has been passed as an argument to the Template class’s substitute() method. The substitute() method requires a dictionary-like object with keys as its argument. The Template() class accepts the template string as its argument. The example below imports the Template class, stores a new instance of the Template class and the string template in a variable. The new Template class’ substitution() method is called and it contains the substitution string to use.

      from string import Template
      greeting = Template('Welcome, $name')

      The Python interpreter returns the interpolated string:

      'Welcome, Frida!'

      The Python 3 Template class provides more readable code, especially when using a single template with various values stored in a
      . For example:

      File: ~/home/username/
      from string import Template
      names = []
      names.append(dict(first='Anais', last='Nin'))
      names.append(dict(first='Octavia', last='Butler'))
      names.append(dict(first='Frida', last='Kahlo'))
      greeting = Template('Welcome, $first $last')
      for name in names:

      When you run the above Python file, the following interpolated strings are returned as output:

      Welcome, Anais Nin
      Welcome, Octavia Butler
      Welcome, Frida Kahlo

      The code in the file is straightforward and readable. You can see that the template to be used derives its substitution values from the dictionaries appended to the names list. Then, a concise for loop, calls the template, and uses the substitute() method to perform the template substitutions.


      Python provides multiple ways to format strings, each with its own advantages and disadvantages. The method you choose depends on your particular use case and your familiarity with each method. Overall, the f-string method provides a good combination of formatting power and readable code. However, you may consider the str.format() method or the Template string class if maintaining security with user-generated strings is a concern. Finally, the string modulo operator is a legacy method for string substitution and formatting. But, it is helpful to familiarize yourself with this method if you are working with a legacy Python codebase.

      Source link

      Introduction to Relational Databases and RDBMSs

      Many programs need to save or store data for later use and read data that is recorded. Although there are many ways to do this, the most common approach is to use a Relational Database Management System (RDBMS).
      , and
      are a few industry-standard open-source RDBMSs that have been widely adopted by software development projects. This guide provides an overview of relational databases and RDBMS concepts.

      What is a Relational Database?

      A database is an application for storing and retrieving data. Although the mechanisms differ, most databases provide an API allowing users to add, delete, access, search, and manage their data. As an alternative to using a database, data can be stored in text files or hash tables. However, this technique is not as fast or as convenient as using a database and is rarely used in modern systems.

      Early database applications evolved into the modern relational database, which allows users to store massive amounts of data. A relational database management system (RDBMS) is a software application that creates and maintains relational databases. An RDBMS no longer forces users to store data in one big table. It provides more structured ways of partitioning the data and is designed for more efficient access. RDBMS applications are optimized for fast reads and writes and bulk transfer of information.

      Database designers conceptualize and organize the data in terms of tables, columns, and rows. A row is also referred to as a record, or tuple. Contemporary relational databases structure the data using the following concepts:

      • Each database contains one or more tables.
      • When the user creates a table, they specify the columns within the table at the same time.
      • Each column represents a specific attribute, or field, within the record. A column is designed to hold data of a particular data type, for example, VARCHAR, which stands for a variable-length string.
      • A table contains a cluster of rows.
      • Each row within a table represents a unique database entry. Each column within the row contains an individual field in that entry.
      • A database table is like a two-by-two matrix. Each square inside the matrix contains a piece of data.

      An RDBMS is considered to be relational because it allows users to define relationships within and between the various tables using keys and indices. A relational database permits a user to provide or generate a primary key for each row. SQL can guarantee that this key is unique within the table. The fields in these tables might be related to one another based on their primary and foreign keys. These relationships help structure and organize the database and limit the amount of data duplication.

      An RDBMS application always provides the capabilities listed below. Individual applications might offer more options.

      • It allows for the creation, definition, modification, and removal of database tables, columns, rows, primary keys, and indices.
      • It accepts SQL queries and stores or retrieves the relevant data, combining information from different database tables as necessary.
      • It guarantees the integrity of the data and the references between the tables. For example, a foreign key always points to a valid row in another table.
      • It automatically updates indices, timestamps, and other internally-generated attributes as required.

      Relational databases use the Structured Query Language (SQL) to query and update the database. For example, an RDBMS client uses the SQL INSERT command to add a new row to one of the database tables. When a user adds a new row, they simultaneously specify a value for each column. Additional SQL commands are used to modify and delete rows, manage database items, and retrieve a list of records meeting specific criteria.

      For example, consider a database for a school. This database has several tables, for teachers, students, courses, classrooms, and so forth. The definition of the Students table might contain columns for the student’s first and last name, ID, grade, family, and more. Each row in this table symbolizes an individual student and serves to represent and collect all relevant information about that student. If the student’s name is “John”, the first_name column in this row contains John. The student ID can serve as the index and primary key and could be used to cross-reference the student in other tables.

      For instance, a simplified Students table can be defined using the structure displayed below. The top row represents the names of the columns in the table. The table below currently has two rows of data, one for each student.

      first_name last_name grade family_id student_id
      John Doe 4 1116 5005
      Jane Student 5 1224 5350

      What are Some Common RDBMS Terms?

      The following terms are frequently used in relation to databases:

      • Column: A set of values of the same data type, representing one attribute within a table. Columns are defined when a table is created.
      • Compound Key: A key consisting of multiple columns. A compound key is used when a single column cannot reliably identify a row.
      • Database: An organized group of data that is stored electronically. A database is usually organized into smaller clusters of information.
      • Foreign Key: An index used to cross-link a table entry to a row in another table.
      • Index: A method of more quickly accessing database entries. An index can be created using any combination of attributes, but implementation is application-specific. A database index is similar to an index in a book.
      • Primary Key: A column serving as an index to uniquely identify a row inside a table. A primary key can either be auto-generated or defined in the table definition. A primary key can be used to locate a specific row within a table.
      • Referential Integrity: An internal database property to ensure a foreign key always references a valid row in another table.
      • Relational DataBase Management System (RDBMS): A type of database system based on relationships between tables and entries.
      • Row: A structured entry within a table consisting of a set of related data. Each row in a table has the same structure, which corresponds to the column specifications in the table definition. A row is also referred to as a record or a tuple.
      • Structured Query Language (SQL): A simplified domain-specific programming language used to manage data in an RDBMS.
      • Table: A collection of database records, consisting of a series of rows and columns. A table can be thought of as a two-dimension matrix of information.

      SQL vs. MySQL

      The terms SQL and MySQL are often mixed up or used interchangeably, but they are not the same. SQL is the standard programming language for querying RDBMS applications. It is used to write database queries and can be used with any database system that supports it. MySQL is a specific instance of an RDBMS that uses SQL. Database users send SQL commands to an RDBMS such as MySQL to read and write data, and to administer the database. There is no application named SQL, so it does not make sense to make a “SQL vs MySQL” comparison. However, the term SQL database is often used informally as a shorthand term for any relational database.

      The SQL Language

      The SQL language is specified as a series of statements. It is not considered a general-purpose imperative programming language like Python, because it lacks a full range of data structures and control statements. It is instead a domain-specific language intended for a single purpose. SQL is designed for the querying, definition, and manipulation of data. It’s also designed to provide data access control. One advantage of SQL is that it can access multiple records using only one command. It does not specify how the database should access an entry.

      The SQL language consists of designated keywords, expressions, queries, statements, operators, and optional clauses. Object identifiers are used to refer to database entities, including tables and columns. SQL supports a large number of predefined data types, such as CHAR, for the character, and INTEGER. Some of the most important SQL operators include =, <>, >, <, IN, LIKE, TRUE, FALSE, and NOT. Recent releases of SQL now support a simple CASE statement. The MySQL documentation contains more information about the SQL
      language structure
      data types
      , and

      Some of the most widely-used SQL statements and clauses include the following:

      • ALTER: Modifies the structure of a database object.
      • CREATE: Creates a database object, such as a table or database.
      • DELETE: Removes one or more existing rows from the database.
      • DROP: Permanently deletes an object from the database.
      • FROM: Indicates which table to use for the query.
      • GRANT: Authorizes a database user to perform a particular action.
      • GROUP BY: A clause to organize output from a SELECT statement.
      • INSERT: Adds rows to the database.
      • JOIN: A clause specifying how to combine and assemble data from multiple tables.
      • MERGE: Combines data from multiple tables.
      • ORDER BY: A clause for sorting the output from a query.
      • SELECT: Retrieves data from one or more tables. This command does not alter the database or change any data.
      • UPDATE: Modifies one or more existing rows.
      • WHERE: A clause to identify the rows a query should operate on. It is typically used with a comparison operator.

      The wildcard * operator is often used in conjunction with the SELECT command. This command instructs SQL to display all columns in the output.

      Below are a couple of examples of SQL queries. The following SQL command displays the name of each class in the Class database for each row where the value of the subject column is math.

      SELECT name
          FROM Class
          WHERE subject="math";

      The next SQL statement creates the Class table. The CREATE statement defines each column in the table, along with its data type, in sequential order. The VARCHAR data type is used to hold a variable-length string. The SMALLINT data type is used for small integer values from the signed range of -32768 to 32767.

      CREATE TABLE Class (
          classID smallint,
          name varchar(255),
          subject varchar(255),
          level smallint

      SQL vs. NoSQL

      NoSQL systems are an alternative to traditional SQL-based RDBMS applications. As the name implies, they use a non-relational model to handle data. They are typically less structured and more flexible than an RDBMS. NoSQL systems are not standardized and can take a variety of formats. However, they are typically key-value, graph, or document-based, not table-based. Some NoSQL applications can use structured domain-specific languages or even accept SQL queries in parallel. A few examples of NoSQL applications include Redis and
      . For more information on NoSQL systems, consult the Linode guide for a
      comparison between SQL and NoSQL databases

      Source link

      Decoding WordPress: An Introduction to Global Styles

      WordPress blocks and Full-Site Editing (FSE) features make building and styling a successful website quick and easy.

      Global Styles can help you unify the appearance of your WordPress site without having to edit single blocks or pages. So whether you want to change your background color or adjust the heading typography, you’ll be able to make your modifications in a single place, resulting in a more cohesive and all-around better User Experience (UX).

      In this post, we’ll walk you through Global Styles. We’ll explain what they are, their benefits, and how the new features work. Then we’ll discuss how to use them to style your WordPress website. Let’s get started!

      An Overview of WordPress Global Styles

      Before working with Global Styles, it’s important to understand what they are and how they operate. This feature works in conjunction with theme.json, a new theme settings file. Developers can use theme.json to define defaults for a site as well as individual blocks. Gutenberg automatically applies this JSON when you place the file in the root directory of a block-based theme.

      This file is one of the most useful tools of the new full site editor in WordPress 5.9. The file lets theme authors share Global Styles as well as Global Settings. WordPress reformats the data taken from these JSON objects and turns it into CSS. Then users can further customize the styles in the WordPress editor.

      In previous iterations of the Gutenberg plugin, you had to register support for the style properties of a block before you were able to work with them in theme.json. Also, in classic themes and older versions, you had to use PHP to define things such as your color choices and fonts. Then you needed to add styles for the front and back end sides of your theme.

      However, with the latest release, when you use a theme with the theme.json file in place, WordPress automatically adds the styles defined there to your stylesheet. You can use this system to add entirely new color palettes, change the typography of themes, and more.

      Why Use WordPress Global Styles

      No matter your skill level, you’ll likely find using Global Styles an intuitive and accessible experience. Overall, it can streamline the web design process by making it easier to change the look and feel of your site. If you’re a WordPress beginner, taking advantage of these Global Styles may mean that you won’t need to hire a developer in order to design your website. Sorry, developers.

      On the flip side though, this new feature might be particularly useful for theme developers. That’s because Global Styles helps WordPress developers style blocks within the Block Editor. This can be highly advantageous, especially for new theme authors. It offers a variety of controls that minimize the need to create custom solutions for styling a site.

      In other words, Global Styles simplifies theme development to a great degree. As a result, it can help developers avoid damaging design mistakes.

      Skip the line and get tips right in your inbox

      Click below to sign up for more how-to’s and tutorials just like this one, delivered to your inbox.

      marketing tips

      Creating the theme.json File

      The theme.json file contains two important parts: settings and styles. Settings refer to a list of global or contextual configuration values that determine how the editor and blocks behave. For example, it influences which controls are enabled by default, which controls are hidden from the User Interface (UI), the available color palette, typography settings, etc.

      Styles handles the theme’s design language and enables theme authors to define elements such as:

      • Font size
      • Line height
      • Background colors
      • Link colors

      If you want to create a theme.json file, you can make a new file of that name and then place it inside the root folder of your theme. All the contents of your file should be inserted inside two curly brackets: { }.

      Next, you’ll use property names and values within double quotes and separated with a colon, for example:

      "property-name": "value"

      The property name can either be a setting or a block name. Below is an example of a very basic theme.json file:

          "version": 1,
          "settings": {},
          "styles": {},
          "customTemplates": {},
          "templateParts": {}

      Version 1 of the theme.json format is the earliest, most stable version. However, version 2 is used starting with WordPress 5.9. While the version section must be the first to follow the opening curly bracket, the subsequent sections can be placed in any order.

      As we mentioned, the two main sections of the file are Settings and Styles. So let’s have a closer look at the presets for each.

      Settings Presets

      Presets refer to the default controls as well as any custom CSS properties and are generated by the values in theme.json. Some of the main preset categories include:

      • Color
      • Typography
      • Layout
      • Spacing

      Categories can also have subcategories. For example, a subcategory of Color could be Color Palette:

      "version": 2,
      "settings": {
      "color": {
      "palette": [

      Each preset also creates a custom CSS property using the “–wp–preset–{preset-category}–{preset-slug}” naming convention.

      There are a ton of presets and examples that you can use to create your theme.json file, so we won’t go over all of them here. However, you can refer to the WordPress Handbook for more detailed guidance.

      Styles Presets

      Styles presets control the styles of objects within blocks. For example, the following would be a way to use the hex value for a background and a Global Styles preset for the text color:

              "version": 2,
      "settings": { ... },
      "styles": {
      "color": {
      "background": "#FBF",
      "text": "var(--wp--preset--color--purple)"

      If we wanted to change the heading color of a block, it would look similar to this:

              "version": 2,
      "settings": {...},
      "styles": {
                     "blocks": {
                   "core/heading": {
           "color": {
            "text": "var(--wp--preset--color--blue)"

      Again, there are nearly infinite examples and ways to use presets for block styles. You can refer to WordPress documentation for a full breakdown.

      There are also Template and Template parts sections. These include the base files of your theme, such as index.html, as well as sections to organize and structure your theme.

      How to Style Your WordPress Site Using Global Styles

      If you’re looking for a beginner-friendly way to use Global Styles to style your website, you can use the Global Styles interface with a WordPress block theme. Note that you will only have access to the Styles interface with WordPress 5.9 or higher.

      Choosing a Block-Based Theme

      First, you’ll need a block-based theme. To find one, you can navigate to the WordPress Theme Directory from your admin dashboard by browsing to Appearance > Themes > Add New. Next, you can click on the Feature Filter and select Full Site Editing, followed by Apply:

      WordPress Full-Site Editing theme feature filter

      Once you find a WordPress theme you like, you can hover your mouse over it, then select Install followed by Activate. We’ll be using Twenty Twenty-Two, which may already be installed if you are using WordPress 5.9 or later.

      Accessing the Styles Interface

      Next, head over to your Theme Editor (Appearance > Editor). In the top right-hand corner of the screen, you’ll see a half-shaded circle, which represents the Styles panel:

      WordPress Global styles panel

      When you first click on it, it will present a Styles Welcome Guide. If you need access to this in the future, you can find it by clicking on the three vertical dots in the upper right-hand corner and selecting Welcome Guide.

      The preview window shows you how the current style of your theme looks. Under the Styles panel, you’ll find settings for:

      • Typography
      • Colors
      • Layout
      • Blocks

      Let’s take a closer look at each.


      Under Typography, you can manage the typography settings for two elements: Text and Links.

      You can change the font family and size:

      WordPress Global Styles typography settings screen

      You can also adjust the line height and select a font-weight. You’ll have these same options for your links. When you’re done, remember to save your changes.


      Under Colors, you’ll find the default color presets that come with your theme. To create your own color palettes, you can enter the HEX value numbers or use the drag-and-drop color picker to generate your preferred colors:

      WordPress Global Styles color settings

      You can also rename the colors to something more identifiable or descriptive than the standard hexadecimal alphanumeric values. You can add custom gradients, apply duo-tone filters to images, and more.

      Next, you can modify the colors for three main elements: Background, Text, and Links. You can also select any of these elements to customize the styling. The changes will be applied instantly as you are editing.


      Under Layout, you can adjust padding and other elements. This is straightforward and can be very useful when you need to make a minor adjustment (for example, for the sake of page symmetry).


      Finally, you can change the appearance of individual blocks. After you select Blocks from the Styles panel, you’ll find a list of blocks on your site.

      Let’s say you wanted to change the style of your Heading block. You can select Heading from the list, then adjust its Colors and Typography settings:

      Styling options for the WordPress Heading block

      When you’re done, you can click on Save. If you ever want to revert back to the theme styles you had before making changes, you can navigate to the Styles panel, click on the three vertical dots, and then select Reset to defaults.

      A Better Way to Use and Style WordPress

      WordPress is continuously working to improve the editing experience for its users. Now, thanks to Global Styles, theme development has just become that much easier for both beginners and seasoned professionals.

      As discussed in this post, you can create a theme.json file to apply Global Styles configurations to your theme. You can also use the Styles editor with a block-based theme to customize the appearance of your site. All this makes designing a successful website a breeze.

      DreamHost is a team of experienced web experts. We understand the importance of optimizing your WordPress experience. We promise to support your efforts using the latest open-source tech and award-winning support. Check out our Managed WordPress hosting plans today to learn more!

      Do More with DreamPress

      DreamPress Plus and Pro users get access to Jetpack Professional (and 200+ premium themes) at no added cost!

      Managed WordPress Hosting - DreamPress

      Source link